-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
objects with single key are not nested #29
Comments
Hi there, The default delimiters are Module:import hone
optional_arguments = {
"delimiters": [" ", "_", ",", "|"] # include whatever delimiters you like
}
Hone = hone.Hone(**optional_arguments)
schema = Hone.get_schema('path/to/input.csv') # nested JSON schema for input.csv
result = Hone.convert('path/to/input.csv', schema=schema) # final structure, nested according to schema Let me know if you have any other questions! |
Hi, My issue is that if you have a csv like this (using default delimiter values):
I believe you should get a json like this:
It makes sense to me, but there might be some issues with this approach. What do you think? |
Oh I see what you're saying now. The idea behind hone was that it would only add structure to your data if there was more than one column that could be nested under a key. It might also get out of hand if you have multiple delimiters in a column name. For example, something like If the CSV column names are chosen well, then I can see why you might prefer to split it the way you described, but I don't think it should be the default behaviour for the reasons described above. However, if you want to add an optional argument that a user can use to make hone behave this way, then that would be totally cool with me! If you need the feature more urgently, you can also modify the schema that hone generates to fit your needs. For example: import hone
optional_arguments = {
"delimiters": [" ", "_", ","]
}
csv_file_path = "path/to/input.csv"
Hone = hone.Hone(**optional_arguments)
schema = Hone.get_schema(csv_file_path )
del schema["adopted_since"]
schema["adopted"] = { "since": "adopted_since" }
result = Hone.convert(csv_file_path, schema=schema) |
If I use a delimiter
|
for example and I have a column name likelvl1|lvl2
, the resulting JSON structure looks like"lvl1|lvl2" : <value>
. I believe it would make more sense if the result would be"lvl1":{"lvl2":<value>}
. What is the reasoning behind this? As I needed it, I've prepared the code adjustments for this and I can create a pull request for it. Thanks!The text was updated successfully, but these errors were encountered: