Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use fgetcsv for tab delimited file

Tags:

php

Is it possible to use fgetcsv in PHP to open a tab-delimited file?

like image 876
Brian Avatar asked Apr 06 '10 00:04

Brian


People also ask

Can a CSV be tab-delimited?

A CSV (Comma Separated Values) or Tab-delimited Text (or Tab Separated Values) file is a text file in which one can identify rows and columns. Rows are represented by the lines in the file and the columns are created by separating the values on each line by a specific character, like a comma or a tab.

How do I make a CSV tab-delimited?

Again, click the File tab in the Ribbon menu and select the Save As option. In the Save As window, select the CSV (Comma delimited) (*. csv) option in the Save as type drop-down menu. Type a name for the CSV file in the File name field, navigate to where you want to save the file, then click the Save button.


1 Answers

$csvData = fgetcsv($fileHandle, 0, "\t"); 

Where $fileHandle is a valid file handle. The 0 is just to tell the function not to limit seeking through lines (however you can change this to suit, the docs do say not imposing a limit decreases performance).

like image 107
alex Avatar answered Oct 01 '22 02:10

alex