GithubHelp home page GithubHelp logo

javascript-csv-array-example's People

Contributors

nathansebhastian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

javascript-csv-array-example's Issues

get data from outside

Hello, I thank you for Your code. I have a Question.

`
myForm.addEventListener("submit", function (e) {
e.preventDefault();
const input = csvFile.files[0];
const reader = new FileReader();

  reader.onload = function (e) {
    const text = e.target.result;
    const data = csvToArray(text);
    document.write(JSON.stringify(data));
  };
  
  reader.readAsText(input);
});

`

how can I get data from outside for use it in anover functions as Parameter?

best regards
Wilhelm

CSV file in server location

Hello - I appreciate your work on this. Do you know how I might be able parse a file that's sitting in a directory on a server? Your code allows the user to add a file but I would need to parse from a file that's not uploaded manually. Thank you

Breaks when delimiter showing up inside row values

My source CSV has values that contain commas. Every value has double quotes around it. How would I change this code to skip the commas that are inside of double quotes?

Code example:
ID,Full Name,Address
"85DD-019F","Alice","123 Park Ave, Topeka, KS, 66618"

I've tried setting the delimiter to '/,(?=(?:(?:[^"]*"){2})*[^"]*$)/' (from this link) but then the array is the entirety of the row, then a bunch of undefined to fill out the rest of the values.

double quotes around csv fields

Hi Nathan,

Thanks for your excellent code. I am using it to read a CSV into my app from google sheets.

My issue is some of my fields have double quotes put around them by google sheets because the actual field contains commas.

e.g.

field1, "field 2, more field2, even more field2", field3

This seems to break the code somewhere in here I guess:

const values = row.split(delimiter);
const el = headers.reduce(function (object, header, index) {
object[header] = values[index];

Any ideas which bit is breaking? I guess it must be the 'split' function??

I'm a very average javascript coder :)

Thanks much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.