farling42 / obsidian-import-json

Plug-in for Obsidian.md which will create Notes from JSON files
MIT License
85 stars 5 forks source link

"Too many fields" Error #45

Closed mmngtb closed 1 year ago

mmngtb commented 1 year ago

Hello,

The plugin repeatedly gives me this error:

Plugin:obsidian-import-json:20962 [ { "type": "FieldMismatch", "code": "TooManyFields", "message": "Too many fields: expected 1 fields but parsed 7", "row": 0 }, { "type": "FieldMismatch", "code": "TooManyFields", "message": "Too many fields: expected 1 fields but parsed 7", "row": 1 } ] convertCsv @ plugin:obsidian-import-json:20962 eval @ plugin:obsidian-import-json:21328 eval @ plugin:obsidian-import-json:49 __async @ plugin:obsidian-import-json:33 input5.onclick @ plugin:obsidian-import-json:21306 plugin:obsidian-import-json:20964 { "delimiter": ",", "linebreak": "\n", "aborted": false, "truncated": false, "cursor": 1370, "fields": [ "Question|Answer|References" ] } plugin:obsidian-import-json:21121 generateNotes('[object File]', 'undefined', [object Object] )

I'm using a pipe delimiter in this file and I don't think it's decoding my file correctly. I could be wrong. Does anyone have a solution to this?

Thanks

farling42 commented 1 year ago

Are you using pipe separators on the first line of the file? It is the first line that determines how many columns your table has (as well as the name of those fields).

farling42 commented 1 year ago

Oh, I just noticed in the last section of your log that it is using a comma as the delimiter. You might have to explicitly set the delimiter in the plugin's settings.

farling42 commented 1 year ago

Actually I don't have a field in which to enter the delimiter; it is supposed to be detected automatically.

I see that the decoder is reading the entire first line as a single field "Question|Answer|References".

I am using the Papaparse library to do the decoding. As a test can you check if putting spaces either side of the "|" in the first line causes the detection of separator to work properly?

mmngtb commented 1 year ago

Thank you, adding the pipe on each end solved the issue! I appreciate the quick response!