Converting variable in javascript to a CSV file -
Basically I have a string variable that is composed of two other variables separated by commas:
< P> code> items = "pencil"; Zodiac = 5; Entry = item + "," + amount; * Export entry in CSVThen the "entry" variable should be in the correct format to save as a separate file from a comma. Is there any such command that will take this variable and save it as a CSV or any other format which can be opened easily for use later? The entry variables will change and new information will need to be added to the CSV file if it already exists. So we say that if we also had:
items = "paper"; Zodiac = 25; Entry = item + "," + amount; Export Entry for CSV
should be the resultant CSV file:
pencil, 5
paper, 25I have other questions There is a bit of searching through, but most people are trying to do more complex things (eg, dealing with server vs. client-side issues), while I'm trying to explain how I get data I am on my own computer in javascript The saved file appears that is not the case, however, to ask a number of questions, however. I am convinced that there is a simple answer and hope that only one command or two, though I am pained through many semi-related posts which are not very clear, so I thought it would be faster.
using some
FileSaver implementation is absolutely possible for me to believe Is that it exists originally on IE10, but still needs a shimm on other browsers.
I have written a light weight client-side CSV generator library which can be useful.
Scroll down in the title that says client side CSV file generator
Like I said, do a job for
FileSaver < / Code> Call to handle the implementation
window.saveAs () .
Check the solution of Eli Gray
When you get the place, you just generate and save the CSV files when you fly:
< Code> var propertyOrder = ["name", "age", "height"]; Var CSV = new CSV (Property Order); Csv.add ({name: "enders", age: 38, height: "178 cm"}); Csv.add ({name: "John Doe", age: 50, height: "184 cm"}); Csv.saveAs ("people.csv");
Comments
Post a Comment