I have a .CSV file that has 3 columns file that needs to be converted to 3 arrays(one for each column(obviously))
The .CSV is sever side and not client side, if that matters
The .CSV is sever side and not client side, if that matters
|
Javascript
CSV to javascript array |
|
Nov 10, 2019 06:03 AM
(This post was last modified: Nov 10, 2019 06:09 AM by MavenGradle.)
CSV files are comma separated. It's literally in the name. Do note that sometimes the values between the separators are enclosed in quotation marks in order to prevent the separator from being broken. For more information, there is an entire standard in regards to CSV files that you have to take into account if you want to do this properly:
https://tools.ietf.org/html/rfc4180 Since you're using JavaScript do to this, you can very easily create a function that, according to the CSV standard, takes out all the values and pushes the values into an array: https://developer.mozilla.org/en-US/docs...Array/push I don't really know why you need 3 arrays for this? It makes no sense to me. You could very easily push the values into a single JSON object, much like this: Code {![]() (Nov 10, 2019 06:03 AM)MavenGradle Wrote: CSV files are comma separated. It's literally in the name. Do note that sometimes the values between the separators are enclosed in quotation marks in order to prevent the separator from being broken. For more information, there is an entire standard in regards to CSV files that you have to take into account if you want to do this properly: alright, thank you. I needed the data to be printed out into a graph/chart, I was able to find a solution. Thanks anyways, much appreciated. 🎉 🎉 (Nov 10, 2019 06:03 AM)MavenGradle Wrote: CSV files are comma separated. It's literally in the name. Do note that sometimes the values between the separators are enclosed in quotation marks in order to prevent the separator from being broken. For more information, there is an entire standard in regards to CSV files that you have to take into account if you want to do this properly: Well we can also Map the items out into Array instead of pushing: Maybe say like this? PHP Code |
|
|
| Possibly Related Threads... | |||
| Thread / Author | Replies | Views | Last Post |
| [Javascript] by flexing_99Apr 29, 2023 12:02 AM | 3 | 270 |
Apr 29, 2023 12:02 AM Last Post: Zgh600 |
| [Javascript] by FacewipeSep 7, 2021 03:44 AM | 1 | 177 |
Sep 7, 2021 03:44 AM Last Post: kitkatas |
| [Javascript] by Button5Aug 8, 2021 07:32 AM | 1 | 329 |
Aug 8, 2021 07:32 AM Last Post: MavenGradle |