How to read the all column names of an uploaded csv file - javascript

In my project I am using ngx-file-drop and angular 5.2.
I want to get all the column names of an uploaded CSV file. How can I do that?

I would recommend using csvtojson library, then you could convert your data from the file to a json object.
https://www.npmjs.com/package/csvtojson#from-csv-file-to-json-array

Related

How to create javascript File object for local CSV file to read in and convert to JSON?

I am working in ReactJS, my app is currently running locally with Create React App. I have a .csv file in my project src folder that I need to read in and convert to an array of javascript objects using Papaparse, but can't figure out how to create a File object to pass into the Papa.parse() method. The File documentation seems to all refer to creating a new file or reading a file passed by a user through drag and drop, etc. I can't find a reference to creating a File by pathname. I was previously successfully reading a json file stored in the same place in the src folder, but now need to switch to reading csv and converting to array of JS objects. There is no problem with the formatting of the .csv, I copied several lines of it as a multiline string and it was correctly parsed to json with Papa.parse(), but I don't understand how to pass in a File.
You are dealing with data on your server, not data the user is picking from a file <input>. Use URLs, not File objects.
You need to give the CSV file a URL (how you do that depends on the particular server you are using, this question seems to cover it if you are using the Webpack development server).
Then you need to pass that URL a per the documentation to Papa Parse.
Papa.parse("http://example.com/file.csv", {
download: true,
complete: function(results) {
console.log(results);
}
});

Converting table head in CSV file to schema field

I am demanded to define a schema for a CSV file using Mongoose, but after I peeked through the CSV file, I found there are almost a hundred fields or columns in the CSV file. I know how to define a schema in Mongoose using only a few fields, but I am totally unsure how to define such schema. Is there an efficient way of doing that, such as reading through the head of the CSV and copy those heads into an javascript object and then pass the object to the mongoose.Schema()
Using this package https://www.npmjs.com/package/csvjson you can convert csv file to JSON.
Then secondly, you can convert the generated JSON to mongoose schema using this package, https://github.com/topliceanu/mongoose-gen.
You may need to edit the field types. I hope it works for you.

Javascript and SOAP (CUCM)

I'm using this code (http://blog.darrenparkinson.uk/2014/04/accessing-cisco-administrative-xml-axl.html) to make connection with CUCM.
But, this code returns the XML in console. I need a XML file or .CSV file for open in Excel.
How can I do this?
Tks
Are you trying to get a list of all the Route Patterns on the Call Manager? etc. I guess this should help:
https://medium.com/#chandupriya93/xml-to-excel-conversion-using-node-js-d70296ba3bea
This uses an xml2js and json2xls module to parse the XML file into a JSON file and finally convert into XLS.
Hope this helps.
Ank
Another choice is camaro. You can take the element you want as an array easy. then convert that to csv
You can see the sample in that package

Write a code to convert excel data to json data

Can you please tell me how to convert data stored in excel sheet manually into Json data using javascript code??
Consider a excel sheet name: task.xlsx and
Path:C:\rex\task.xlsx
Thanks!!!
First you don't want to parse the xlsx sheet that will be a huge pain. It will be much easier to export to a csv, then convert the csv to JSON. Here is a similar question parsing csv into hashes.
Parsing CSV to Array of Hashes
I can recommend this package from NPM that can parse XLSX file (like task.xlsx) https://www.npmjs.com/package/excel

Looking for suggestions. Javascript object data to xls

I´ve a Javascript object with all the data that I need to store on xls file. What could be the better way? Apache POI? Jasper-Reports? I´m not sure about the correct choice.
Thanks!
If you just need to import it with Excel I would suggest creating an CSV file out of the data instead.
This can easily be done with JavaScript and Excel can import that format.

Categories