- JSON Formatter/Viewer
Format, minify, visualize and validate JSON.
- JSON Diff
Compare two JSON objects.
- JSON Schema Validator
Validate JSON schema online
- Base64 Encode/Decode
Encode and decode Base64.
- URL Encode/Decode
Encode and decode URL.
- UUID Generator v4 / v1
Generate UUIDs in v4 and other versions.
- Text Hash
Generate cryptographic hashes from your text input using a wide variety of algorithms.
- File Hash
Generate cryptographic hashes from your file using a wide variety of algorithms.
- JWT Decoder & Validator
Decode and validate JSON Web Tokens.
- CSV Viewer
View CSV data in a table.
- CSV to JSON Converter
Convert CSV to JSON.
- JSON to CSV Converter
Convert JSON to CSV.
Javascript Read CSV
A concise, practical guide to reading CSV files in JavaScript. This snippet presents a common yet powerful method to extract and use data stored in CSV format.
const parseCSV = (data) => {
const lines = data.split('\n');
return lines.map(line => line.split(','));
};
fetch('./file.csv')
.then(response => response.text())
.then(data => console.log(parseCSV(data)));
This code snippet is a simple, effective method for reading CSV data in JavaScript. First, it defines a parseCSV function. This function splits the CSV data into individual lines, then further splits each line at the comma, thus transforming the CSV data into a two-dimensional array for easy accessibility.
After defining the function, the code fetches a CSV file called 'file.csv'. Once fetched, the response is converted to text. Then the parseCSV function is applied to the textual data. The resulting two-dimensional array is logged in the console for inspection.