TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Npm module that makes easy to convert JSON to CSV

64 pointsby kauegimenesalmost 8 years ago

11 comments

billforsternzalmost 8 years ago
Off topic rant I need to get off my chest. Yesterday I troubleshooted a bizarre problem. New versions of Excel don't necessarily understand the simplest CSV files. Reason: They forgot that the C in CSV stands for comma, and instead expect whatever character happens to be set as the 'delimiter' character in the Windows regional preferences. Here in New Zealand, it seems that character is semicolon instead of comma. For some reason. I think Excel was finished circa 2000 and now they focus mainly on making it worse.
评论 #14517903 未加载
评论 #14517054 未加载
评论 #14517303 未加载
评论 #14517427 未加载
评论 #14517454 未加载
评论 #14521922 未加载
评论 #14517122 未加载
评论 #14517070 未加载
评论 #14517170 未加载
评论 #14517184 未加载
dc2almost 8 years ago
For a <5Kb library, I recommend removing the underscore dependency. You should make this as lightweight as possible if you want a lot of adoption.
评论 #14517038 未加载
评论 #14517032 未加载
评论 #14517044 未加载
TAForObvReasonsalmost 8 years ago
The most popular NPM module for JSON to CSV conversion is json2csv: <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;json2csv" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;json2csv</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;zemirco&#x2F;json2csv" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zemirco&#x2F;json2csv</a>
评论 #14517207 未加载
评论 #14517021 未加载
codezeroalmost 8 years ago
Cool, I immediately wondered if you handled a lot of the tricky CSV things like quotes and internal commas, it looks like it does a good job.<p>Comparing against Numbers (probably a bad comparison?) I am seeing one slightly different result:<p>If I have a field that is &quot;hehe&quot;<p>It&#x27;s encoded as &quot;&quot;hehe&quot;&quot;<p>It looks like Numbers adds the enclosing quotes:<p>&quot;&quot;&quot;hehe&quot;&quot;&quot;<p>I only see enclosing quotes if there&#x27;s a comma:<p>&quot;hehe,hehe&quot; -&gt; &quot;&quot;&quot;hehe,hehe&quot;&quot;&quot;<p>Anyhow, I&#x27;m not sure what the &quot;correct&quot; thing to do here is, if there is one, just a heads up!
评论 #14516862 未加载
评论 #14517501 未加载
dansoalmost 8 years ago
In the complex object example, what&#x27;s the usecase for turning that nested object into a multi-column CSV? I guess the overarching question is, why turn a single object at all into a CSV? It&#x27;s just as machine&#x2F;human readable as the JSON version of it, and there&#x27;s no particular benefit in using either structure as it&#x27;s not data meant to be processed in bulk.<p>The complex array usecase is where an opinionated-type of conversion tool is particularly needed, but I wonder why it behaves like this:<p><pre><code> name: &#x27;Robert&#x27;, lastname: &#x27;Miller&#x27;, family: null, location: [1231,3214,4214] </code></pre> lastname,name,family.type,family.name,nickname,location Miller,Robert,,,,1231,3214,4214<p>Why not have `location_1, location_2, location_3`, instead of having a single location column? The latter implementation makes the data difficult to quickly use in a program (like a spreadsheet).
评论 #14517011 未加载
评论 #14516921 未加载
评论 #14517131 未加载
评论 #14517561 未加载
kmike84almost 8 years ago
From a Python developer point of view, design is a bit surprising - why isn&#x27;t it created as two separate libraries:<p>1) csv writer (and reader?) which takes care of all csv dialects crazyness; 2) a library which &quot;flattens&quot; nested objects&#x2F;arrays?<p>(1) is not opinionated (besides a few API choices), it just has to be correct; it doesn&#x27;t make much sense to re-implement (1) everywhere.<p>(2) can be more opinionated, it is easy to disagree with design choices, there is more room for personal preferences.<p>For example, in Python there is CSV stdlib module, and for (2) there are libraries like <a href="https:&#x2F;&#x2F;github.com&#x2F;scrapinghub&#x2F;flatson" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;scrapinghub&#x2F;flatson</a>. Why put both to the same library? Is it something ideomatic in node.js world, with a deeper reason to design libraries this way (e.g. download size), or is it just an oversight?
评论 #14522701 未加载
BrandiATMuhkuhalmost 8 years ago
Converting JSON to CSV is a usable&#x2F;good way when analysing NoSQL data. However I&#x27;m trying try find since a while a data analysis&#x2F;query tool for JSON data itself. I saw that mixpanel made a query tool&#x2F;language called JQL (JavaScript query language) which seems nice. Also RQL (rethink query language) seems nice too. But I can&#x27;t​ find a simple tool in which I can import my JSON data and query it. It should be similar to SQLite-browser. Simply import your CSV&#x2F;JSON file, and query it.
评论 #14518201 未加载
评论 #14518009 未加载
chidalmost 8 years ago
There&#x27;s a similar command in pandas called json_normalize (<a href="http:&#x2F;&#x2F;pandas.pydata.org&#x2F;pandas-docs&#x2F;stable&#x2F;generated&#x2F;pandas.io.json.json_normalize.html" rel="nofollow">http:&#x2F;&#x2F;pandas.pydata.org&#x2F;pandas-docs&#x2F;stable&#x2F;generated&#x2F;pandas...</a>)
freezer333almost 8 years ago
Nice! If you want to do something similar with Excel xlsx this works: <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;jsonexcel" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;jsonexcel</a> Not sure how it handles huge arrays though...
评论 #14517479 未加载
madamelicalmost 8 years ago
This is a new one. Most people want to go the opposite way.<p>Either way, neat addition.
评论 #14516954 未加载
tambourine_manalmost 8 years ago
Just yesterday I was looking for the other way around, CVS-&gt;JSON
评论 #14521496 未加载