Replies: 6 comments 6 replies
-
This is another example of a csv issue and awk. The split command below is using , as a separator. But everywhere I have a full sentence with a comma it is adding an extra field..... aaarg!
|
Beta Was this translation helpful? Give feedback.
-
I will get Tsv setup as an option sometime in the next 2 weeks! 👍 |
Beta Was this translation helpful? Give feedback.
-
FWIW you can use # CSV to TSV
csvtool -t COMMA -u TAB cat in.csv > out.tsv
# TSV back to CSV
csvtool -t TAB -u COMMA cat in.tsv > out.csv or as part of a pipeline:
(You can use Is the botched Google docs import directly from BrainBrew's CSV export? (or was it from the |
Beta Was this translation helpful? Give feedback.
-
FYI: I also sent a message to the coreutils mailing list: Not sure if I am doing this correctly, but I seem to have a problem sorting when the first column of my data contains a uuid often with embedded commas. Does sort deal with this properly? My file contains this: (where the first and last fields may contain embedded commas. "}~,)4",nɛgɛso,yq,,vélo,,,,,0630 The following is not correctly sorted by the second field However the second column alone will sort fine: Thanks for any enlightenment! |
Beta Was this translation helpful? Give feedback.
-
I also noticed something else extremely weird. (No I don't think with brainbrew; either with Anki or csvtool)
when I run:
and then take a look in vim i only have 7 fields (same if I import to Google docs or libre office calc).
Oddly it looks ok here. But the > (representing tabs) before the html are not registering as fields. And I can see that vim is reporting on my status line one of the fields containing html contains some wierd control characters. (^I^I). You can also see below it is reporting that as field 6 of 7. (When there should be 18)
I didn't find any control characters in the Main.csv from brainbrew. Only once csvtool touched it. But why would csvtool be adding this? There is nothing else weird in the data. Even the guid here doesn't contain anything suspect. Kind of a paradox that I'm finding next to impossible to sort a csv file on the command line, but Import the file to Google, LibreOffice, and click on the header and its sorted. |
Beta Was this translation helpful? Give feedback.
-
Feature added #35 👍 Lemme know if there's any issues |
Beta Was this translation helpful? Give feedback.
-
Hi there....
Just a couple of examples of challenges with csv format. I need to sort some 2400 rows of data in order to eliminate redundant data. The first field of my data is the guid, the second field should be the sort order.
When I run:
You can see that the sort order is totally botched. (I was going to use other terms....)
is not sorted corrrectly.
I have been using other scripts with awk using:
with some success, but even then I have had issues with the tags field which has comma delimiters within comma delimiters...
https://docs.google.com/spreadsheets/d/e/2PACX-1vRTiH57lVffHLnNcw8XUVb2A2ah3PgAkw-e_2iL4z45ONrkPN8wOjto38-QhT1UsAEcL-_9g3z5mgJN/pubhtml
If you scroll over to column bh, you can also see the problems with this data. (The tags are not all in the same column.)
Otherwise in the brainbrew file editiing with neovim this data is FINE. I do not have an issue. I just can't sort the data (easily).
I have been able to use awk to convert to TSV using an FPAT instead of FS. Then I sort the data and convert it back to CSV.
But this is a pain. And it has caused some recoverable errors, I am assuming that come from the uuids.
As I see things there are 3 issues with my data and brainbrew.
There are also lines with embedded html that also cause issues:
(Normally those > should be pipes (as displayed by csv.vim) but they are not, and so the line is showing 53 fields instead of 63.
Anki's default text export format is in tsv which avoids all these issues.
Python does seem to deal better with all this than awk and sort.
Would love to see brainbrew's python run recipes/anki_to_source.yaml (and back) that produces a tsv file! Much easier to work with!
Thanks so much for your awesome anki addon!
Beta Was this translation helpful? Give feedback.
All reactions