The d3.csv() function in D3.js is a part of the request API that returns a request for the file of type CSV at the specified URL. The mime type is text/CSV.
d3.csv(url[[, row], callback])
- url: It is the URL of the file that is to be fetched.
- callback: It is the function that is to be performed after the file is fetched.
Return Value: It returns a request for the file of type text/csv.CSV
Example 1: Fetching a file named sample.csv which is stored in the same location where the index.html is present. Please create the sample.csv file if not created already. Data of the CSV file is given as a comment in the code below.