Read a Large CSV File in the Most Optimized Speed/Time

Updated Dec 22, 2025

Reported In

Software

  • LabVIEW

Operating System

  • Windows

Issue Details

I would like to read specific ranges (e.g., first few rows/columns, last few rows/columns) from a large CSV file (approximately 1GB, 15,000 rows × 100 columns) using LabVIEW. The standard Read Delimited Spreadsheet.vi processes the entire file, resulting in slow performance. I want to avoid reading all data and filtering afterward and prefers not to split the file or convert it to TDMS format. 

Solution

To optimize reading speed and avoid loading the entire CSV file, we can use the start of read offset parameter in the Read Delimited Spreadsheet.vi. This allows us to begin reading at a specific byte position in the file, so only the required portion is processed. This method significantly reduces read time for large files. 

 

 

Explanations: 

1. File Opening and Size Calculation 

  • The VI opens the file specified by File Path using the Open/Create/Replace File function. 

  • It then queries the file’s total size in bytes. 

2. Offset Calculation 

  • The user provides a Percentage % value (0–100). 

  • The VI divides this value by 100 to get a fractional percentage. 

  • It multiplies the file’s total size by this fraction to compute the Offset size (in bytes)—the starting point for reading. 

3. Reading Data 

  • The VI calls the Read Delimited Spreadsheet (string) sub VI. 

  • It passes the calculated offset, the number of rows to read (number of rows (all: -1)), and the file path. 

  • The sub VI reads the specified number of rows starting from the offset. 

4. Output 

  • All rows return the data read from the file. 

  • EOF indicates if the end of the file was reached during the read. 

  • Total size (in bytes) and Offset size (in bytes) provide file metrics. 

 

Image below shows the accuracy of the VI when the percentage is set as 0 (obtain data from the very beginning of the file) and number of rows is set as 5 (obtain only 5 rows of data from the starting row). 

 

 

Additional Information

  • We are only required to modify File Path, Percentage %, and number of rows to obtain result in this VI sample attached to this article.
  • Please kindly find the Sample data file. txt and Read CSV sample.vi in the attachments for testing purpose).  
  • Please refer to attachment for modified shipping examples for LabVIEW.
  • The attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject to the Sample Code License Terms which can be found at: https://ni.com/samplecodelicense.