I have an xls worksheet I wish to export as a text or csv file to import
with fgetcsv()
The 'save as' function on excell lets me save as a comma separated value or
tab delimited text files.
Trouble is, some of my cells already have commas in them, so a tab or
something else would be better.
In the delimiter option of fgcsv(), can you specify a tab and how?
My other option (but a bit of a chore) is to copy and paste the xls data
into word, then replace all the tabs with something like ; that dosn't
appear in the cells.
thanks 2 6221
Stephen Preston wrote: I have an xls worksheet I wish to export as a text or csv file to import with fgetcsv()
So go ahead and do it; there shouldn't be any problems...
The 'save as' function on excell lets me save as a comma separated value or tab delimited text files. Trouble is, some of my cells already have commas in them
Doesn't matter; Excel encloses fields with commas in them in double
duotes, like this:
A simple field,"A field with a comma (,) in it",Another simple field
fgetcsv() understands this as well...
a tab or something else would be better.
This is a matter of opinion... :)
In the delimiter option of fgcsv(), can you specify a tab
You can if you want to:
fgetcsv($handle, 10240, "\t");
Note that since a custom delimiter is the third argument, the second
argument (the maximum length of a CSV string) must be specified...
For more information, see documentation on fgetcsv(): http://www.php.net/fgetcsv
Cheers,
NC
Stephen Preston: Trouble is, some of my cells already have commas in them, so a tab or something else would be better.
No, that doesn't follow. You can hide your delimiter (commas by
default) by double quoting them (double quotes by default, but any
character you set the fourth argument to).
In the delimiter option of fgcsv(), can you specify a tab and how?
\t or however you insert tabs (got a tab key?).
My other option (but a bit of a chore) is to copy and paste the xls data into word, then replace all the tabs with something like ; that dosn't appear in the cells.
Well, I was about to say that TSV has the advantage that it boasts
its own registered MIME type, text/tab-separated-values; but lo and
behold text/csv was registered in October 2005. http://www.ietf.org/rfc/rfc4180.txt
--
Jock This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joe Randstein |
last post by:
Hi!
I get CSV-data from a post-request. How can I work on that?
Currently I save the data to a temp-file, then read it back with
fgetcsv and then delete the temp-file. That works, but I don't...
|
by: Jonaed |
last post by:
This is my code:
$handle = fopen ($file, "r");
$c = 1;
while (($values_list = fgetcsv ($handle, 1000, ',', '"')) !== FALSE)
{
echo $c . "<br>\n";
$c = $c +...
|
by: tjonsek |
last post by:
I am working with directories in PHP for the first time. I have code
that I've changed multiple times to try different things. I would think
this is pretty standard fare so I'm not sure why I can't...
|
by: et |
last post by:
fgetcsv() do unwanted "left trim" on fields started
with locale characters (code page win-1250).
Problem persist only if local character is first character in field
for example, let say that C...
|
by: mantrid |
last post by:
I am using fopen() and fgetcsv() to open an excel file and extract data for
upload to mysql database. The doesnt seem to be a parameter in either of
these functions for ommitting the first row of...
|
by: m6s |
last post by:
1. After hours of researching, I used these snippets :
void Object::TokenizeLines(const string& str, vector<string>& tokens, const string& delimiters)
// Skip delimiters at beginning....
|
by: gpaps87 |
last post by:
hi,
i wanted to know whether we can use strtok command to mark delimiters
as tokens as well.In Java,we have a command:
StringTokennizer(String str, String delimiters, boolean
delimAsToken)
...
|
by: jrrdnx |
last post by:
I have a form set up to allow someone to upload a .csv and populate its data into a database using the fgetcsv() function. All of the code works fine because everything in the .csv file is populated...
|
by: code green |
last post by:
I am trying to skip empty rows in a csv file
The manual states But none of these tests seem to work.
Anybody know why
while(($data = fgetcsv($this->handle)) !== false)
{
...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |