I need to read data separated by commas line by line. The csv files are in /data/name.js. Each line has 6 columns, ideally I would like to take the data straight from the file and calculate the maximum and minimum of the 4th and 5th columns which are numbers.
|
Java
Read CSV line by line JS |
|
Nov 3, 2017 09:16 PM
(This post was last modified: Nov 3, 2017 09:16 PM by _wind.)
Basically, you would read the file like any other .txt file and then split each line by commas to create a string array.
Here's a quick demo I wrote that should work: Code import java.io.File;Code taken from https://stackoverflow.com/questions/4510...-file-java (Nov 3, 2017 09:23 PM)_wind Wrote: I'm not sure I'm getting what you're trying to accomplish. Do you have your 50 comma-separated values compiled into a file with a .js extension or do you want to use JavaScript to read 50 different .csv files? I have 55 different .csv files, all with 6 columns. Im trying to read those using javascript.
I don't think it's possible with JavaScript for security purposes. Or maybe you can; I don't know. I would, however, use Node.js or PHP.
Why would you ever need to read 50 .csv files in JavaScript though? Couldn't you parse it in Java and output whatever you need? |
|
|


