Auto-detect format during bulk import #7345

Closed
opened 2025-12-29 20:22:10 +01:00 by adam · 3 comments
Owner

Originally created by @jeremystretch on GitHub (Dec 12, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.4-beta1

Feature type

Change to existing functionality

Proposed functionality

Try to automatically detect the data format (CSV, JSON, or YAML) during import by default. Retain the explicit options as well to ensure the user can specify the format should auto-detection fail.

Use case

Automatically detecting the format is a bit more convenient for the user.

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (Dec 12, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.4-beta1 ### Feature type Change to existing functionality ### Proposed functionality Try to automatically detect the data format (CSV, JSON, or YAML) during import by default. Retain the explicit options as well to ensure the user can specify the format should auto-detection fail. ### Use case Automatically detecting the format is a bit more convenient for the user. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: featurebeta labels 2025-12-29 20:22:10 +01:00
adam closed this issue 2025-12-29 20:22:10 +01:00
Author
Owner

@jsenecal commented on GitHub (Dec 13, 2022):

Could this be done with a series of regex lookup of the first few chars to make it fast?
ie:
{ or [ is json;
^(---\n)?\w+:\n for yaml (something like that)
anything with a series of , and strings a csv...

@jsenecal commented on GitHub (Dec 13, 2022): Could this be done with a series of regex lookup of the first few chars to make it fast? ie: { or [ is json; ^(---\n)?\w+:\n for yaml (something like that) anything with a series of , and strings a csv...
Author
Owner

@jeremystretch commented on GitHub (Dec 13, 2022):

@jsenecal that's my hope. I'd like to stop short of initiating the loader for each type directly, and just infer the type from the first line. If we encounter some scenario where it's not possible to tell, we can just raise a validation error asking the user to specify the type.

@jeremystretch commented on GitHub (Dec 13, 2022): @jsenecal that's my hope. I'd like to stop short of initiating the loader for each type directly, and just infer the type from the first line. If we encounter some scenario where it's not possible to tell, we can just raise a validation error asking the user to specify the type.
Author
Owner

@kkthxbye-code commented on GitHub (Dec 13, 2022):

Do note that YAML is a superset of JSON, so all JSON is valid YAML. The YAML load path will probably support both if we want to simplify the code and only provide two options (CSV or JSON/YAML).

@kkthxbye-code commented on GitHub (Dec 13, 2022): Do note that YAML is a superset of JSON, so all JSON is valid YAML. The YAML load path will probably support both if we want to simplify the code and only provide two options (CSV or JSON/YAML).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7345