Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The article talks about reading and parsing CSV data of unknown variants, but then skips to the solution being using a different format altogether. But you can only switch to a different format if you are producing data, not if you are reading it!

And if you are in control of producing data, just produce strict RFC 4180-compliant CSV data and everybody will be able to read it just fine. There is no need to make your reader’s lives difficult by using yet another non-standard data format.

See also: <https://news.ycombinator.com/item?id=39679753>



I just had a look at RFC 4180. This is the grammar they suggest:

> file = [header CRLF] record *(CRLF record) [CRLF]

I find it kind of wild that you have to have at least one record. Suppose I have a program that lists the events that occurred on a given day. How do I represent the fact that the program ran successfully but that there weren't any events on that day?


Event - Loging Started Aditionally, Loging Ended (for the day) allows you to check for intermediate crashes and startup errors, kinda like a pulse / health check

Not necessarily how I'd do it intuitively, but doesn't seem that crazy


Easy, count running the report as an event.


That isn't a problem of the file format. That's a problem of your process.


> yet another non-standard data format.

Tbf, ASCII delimiter characters have been around since the 1960s. They're not exactly reinventing the wheel


It’s the classic ‘self driving is easy when we modify the world to be what we want’ type solution.


"Politics is easy, the problem is we aren't working together!"


Sqlite isn't a standard per-se, but outputting an Sqlite db file, if you're writing the export code, is easy enough, and enough of a standard that I dare say you'd be doing fine to output .db files marked as sqpite.


[flagged]


Don't use broken tools. The key phrase is "in control of producing data". If you're forced to use Excel, then it's not really you in control, is it?


>> […] Excel […]

> Don't use broken tools.

Tell that to your accounting and finance department and let us know how the message is received.

> If you're forced to use Excel, then it's not really you in control, is it?

In which case the up-thread's advice to "just produce strict RFC 4180-compliant CSV data" is worthless. "Just."

We're stuck with whatever CSVs we get, so 'just' doing X is not an option.


The up-thread’s comment (emphasis mine):

> And *if you are in control of producing data*, just produce strict RFC 4180-compliant CSV data

The point of the comment was that you likely aren’t in control of producing the data, so the article’s recommendation of using an entirely different format is likely also invalid. I’m not sure what you are arguing against as you seem to actually agree with them.


From a pragmatic viewpoint, the CSVs that I get from finance (usually saved as .xlsx) have the same issues for parsing the data as a CSV. But since the issues are consistent, I can automate conversion from .xlsx to CSV, then process the CSV using awk to eliminate errors in further parsing the CSV (for import, analysis, etc.). Sure, I'm essentially parsing the CSV twice but, because the parsing issues are consistent, I can automate to make the process efficient.

Obviously that wouldn't work for CSVs with different structures, but can be effective in the workplace in certain scenarios.


As long as a human didn't generate the file, all things can be automated.

However, if you ever have the misfortune of dealing with human generated files (particularly Excels) then you will suffer much pain and loss.

I once had to deal with a "CSV" which had not one, not two but 6(!) distinct date formats in the same file. Life as a data scientist kinda sucks sometimes :shrug:.


Before 2010 and UTF-8 everywhere , I regularly had the misfortune of dealing with multi encoding CSVs. Someone got CSVs from multiple sources and catted them together. One source uses ISO 8859-1, another -15, another UTF-8, sometimes a greek or russian or even ebcdic was in there. Fun trying to guess where one stopped and the other begun . Of course, none of them were consistent crlf or escape wise.


This is some next level response where Excel is called a “broken tool”. You may not agree with their choices or design or anything else. But calling the entirety of the product isn’t making a strong case towards the prior point.


“Just be in control” is unfortunately bad advice when you’re … not in control.


I don't think the advice is "Just be in control" as much as "Acknowledge you're not in control most of the time."


Importing data generated from Excel: don't, or force RFC 4180-compliant CSV data.

Exporting data into Excel: provide RFC 4180-compliant CSV data, or just generate minimal XLSX files.

Most Excel users generally don't export to CSV (or practice any data sanity conventions); they seem to believe XLSX is a perfectly fine data exchange format for automated use. (“Oh the import broke? I just added an empty row above the headers, because it looked sloppy.”) Those that do understand that automated data processing means you need to be stricter in what you do in the sheet you are exporting tend to understand how to export proper CSV's from Excel as well.


>Those that do understand that automated data processing means you need to be stricter in what you do in the sheet you are exporting tend to understand how to export proper CSV's from Excel as well

exactly right


Do you have some recommendations or references about getting data properly out of Excel. I usually avoid using Excel alltogether if possible. But, obviously that is not always an option.


As someone who has excel open all-day every-day: I don't think excel-employees are "producing" data. We are ingesting CSVs/XLSXs, performing modeling/analysis, and then saving as an XLSX.

I don't know anyone who is saving a CSV unless it is the final model output and another system (e.g. TM1) can only ingest the CSV.

If I accidentally save a spreadsheet as a CSV it is a bad day since I probably lost all my formatting, formulas, and additional tabs.


> Excel

If you’re deep in the Excel world, chances are extremely high that you also have access to SSMS, which has a really, really good data import tool that makes short work of nasty CSV files. The output of this tool doesn’t even have to be SQL Server, it will use any ODBC driver you’ve got installed; you can send the data to Excel or even a new, properly formatted CSV.

And if you want a repeatable package, there is always SSIS.

Look, I would never recommend anyone jump into the Microsoft ecosystem. But when in Rome, do as the Romans do.


> If you’re deep in the Excel world, chances are extremely high that you also have access to SSMS,

Can you provide more information about this?

Like, I'd reinstall windows if this would actually work on messy excel/CSV data.


There is a screenshot here [1]. The trick is to choose the generic "import data" task rather than "import flat file". Then you have a wizard that lets you play around with the specifications, change things up, look at the errors, go back to tweak things, go forwards to try again, etc. The only improvement I can think of is if you could save what you did as a standalone SSIS package (or whatever).

[1] https://www.mssqltips.com/sqlservertutorial/9248/import-and-...


Can you get DSVs out of Excel? If not, it's kinda moot.


How does DSV solve Excel compatibility?


If you have to use Excel, you have to produce whatever data Excel produces. It all depends on what (explicit or implicit) contracts you have in place with whoever is to consume the data which you produce.


Most likely the easiest solution is to use a python library to read the excel file, and another to export the RFC-compliant data.


Where does Excel fall down when exporting CSVs?


I can just not use Excel :-)


Looking it up, using a custom delimited format in Excel is near impossible https://superuser.com/questions/733462/can-ms-excel-use-non-...

So this solution is not going to work for Excel either.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: