Closed pjfalbe closed 3 years ago
Data-Forge CSV handling is based on PapaParse and you can configure its line endings, see docs for various configuration options here:
https://www.papaparse.com/docs#config
When using Data-Forge FS you can pass configuration to the asCSV
function and it is passed onto PapaParse, something like this should work:
df.asCSV({ newline: "\r\n" }).writeFileSync(....);
Or if just using Data-Forge by itself:
const csvData = df.toCSV({ newline: "\r\n" });
I've just done an update to the to DF docs for CSV parsing and output.
You can get to the docs for DF and DF FS from the DF landing page: http://www.data-forge-js.com/
I can't get this to work. I tried .asCSV( { newline : "\n" } ) on line 30 in listing-6.6.js to get rid of Carriage return but it ignores it. My output file is still \r\n
Also, if you vi data/surveys.csv you will get an Icomplete last line warning. If you vi output file it has same warning.
The example you are looking at is on an old version of Data-Forge which doesn't pass the options through to PapaParse.
Please update your version of the code to the latest version (1.8.13).
Use this command in your project:
npm uninstall --save data-forge && npm install --save data-forge
Note that since version 1.3.0 (as documented in the readme) file system support was removed from DF core (so that DF can be used in web browsers as well as Node.js).
That means you need to install DF FS separately now, like this:
npm install --save data-forge-fs
Then update your imports to include DF FS like this:
const dataForge = require('data-forge');
require('data-forge-fs');
Ok I modified listing-6.6.js and did the updates and it worked thank you
On Sun, Dec 27, 2020 at 4:00 PM Ashley Davis notifications@github.com wrote:
The example you are looking at is on an old version of Data-Forge which doesn't pass the options through to PapaParse.
Please update your version of the code to the latest version (1.8.13).
Use this command in your project:
npm uninstall --save data-forge && npm install --save data-forge
Note that since version 1.3.0 (as documented in the readme https://github.com/data-forge/data-forge-ts) file system support was removed from DF core (so that DF can be used in web browsers as well as Node.js).
That means you need to install DF FS separately now, like this:
npm install --save data-forge-fs
Then update your imports to include DF FS like this:
const dataForge = require('data-forge');require('data-forge-fs');
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/data-forge/data-forge-ts/issues/100#issuecomment-751520920, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUZI7HSWVBYWNG6ZNYYCSDSW6VBHANCNFSM4VKIG37A .
Disclaimer
The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.
This email has been scanned for viruses and malware, and may have been automatically archived. Cassens
when I do node listing-6.6.js the output file ./output/surveys-but-only-Australia-using-data-forge.csv is in dos format. Even though I converted ./data/surveys.csv via dos2unix. Didn't know if Data-forge had an option to specify line termination. I work on Linux and it is very important to get line termination correct or else you won't get desired output. In Perl we'd look at the $^O to see if Windows or not and end line correctly.