swiftcsv / SwiftCSV

CSV parser for Swift
MIT License
962 stars 193 forks source link

How to support multiple header rows #84

Closed nikhilpandey4 closed 4 years ago

nikhilpandey4 commented 4 years ago

I have a CSV file where first three rows are header (primary header, followed by secondary header followed by the tertiary header). How to use SwiftCSV in such case?

DivineDominion commented 4 years ago

In that case, I'd parse the CSV with headers/named columns disabled and then use enumeratedRows.dropFirst(3) to get to the content, and enumeratedRows[...3] to get to the header. I'd wrap this is my own data structure to provide more meaningful access to the resulting table.

nikhilpandey4 commented 4 years ago

Can you please explain by example. Am trying to do what you are telling but somehow its not behaving as it should. Some of my data points are getting cut. I don't know but even enumerated rows are looking like an array created out of dictionary, there is no order. So my header rows are being populated at middle of the tableview and some data is being cut. Also my data is date wise data so ordering is important. Any suggestions for this type of situation?

DivineDominion commented 4 years ago

Could you provide a "minimum breaking example" CSV file and show what the print output is, and what you'd expect? That would be helpful!

DivineDominion commented 4 years ago

Closed for now due to inactivity