473,513 Members | 11,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read from 2nd line of CSV file

20 New Member
Hi,

I was working on a questionnaire. the answers to the questionnaire are stored in a csv file which acts as my database. Now i am trying to retrieve the data from the file into a table. However i want to start reading from the 2nd row of the file but am not being able to do so.
the code is like this:
[php]$rowcount = 0;
while(!feof($in))
{
$rowcount = $rowcount + 1;
$row = fgets($in);
if(strlen($row) == 0)
continue;
$rowarray = explode(",",$row);

print("<tr class=\"");

if($rowcount % 2)
print("oddRow");
else
print("evenRow");
print("\">");.
fclose($in)
}[/php]any help will be appreciated.

Thanks

Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that. = moderator
Mar 4 '08 #1
3 4510
ronverdonk
4,258 Recognized Expert Specialist
Welcome to The Scripts!

Do you mean like this? Just test bthe row counter and ignore when 1[php] while(!feof($in))
{
$rowcount++;
$row = fgets($in);
if ($rowcount == 1)
continue;
if(strlen($row) == 0)
continue;
$rowarray = explode(",",$row);
}[/php]Ronald
Mar 4 '08 #2
learnPHP
20 New Member
Welcome to The Scripts!

Do you mean like this? Just test bthe row counter and ignore when 1[php] while(!feof($in))
{
$rowcount++;
$row = fgets($in);
if ($rowcount == 1)
continue;
if(strlen($row) == 0)
continue;
$rowarray = explode(",",$row);
}[/php]Ronald

Yup it worked.. Thanks a lot.. Had been trying all sorts of things...Thank you..
Mar 4 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
You are welcome. See you around next time.

Ronald
Mar 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

40
61166
by: Abby | last post by:
My .dat file will contain information like below. /////////// First 0x04 0x05 0x06 Second 0x07
4
2461
by: yo_mismo | last post by:
Hi everyone, I'm trying to read the first line of a file this way: .... .... .... .... new_line=0; while((read=read(fd, &info, sizeof(info))) > 0 && !new_line){ if (strcmp(&info, "\n") !=...
4
2712
by: ESPN Lover | last post by:
Below is two snippets of code from MSDN showing how to read a file. Is one way preferred over the other and why? Thanks. using System; using System.IO; class Test { public static void...
34
2759
by: Ross Reyes | last post by:
HI - Sorry for maybe a too simple a question but I googled and also checked my reference O'Reilly Learning Python book and I did not find a satisfactory answer. When I use readlines, what...
35
11336
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
0
5750
by: lovecarole | last post by:
hi, i am the student who should write a program about reading wav file and do the DFT. actually i don't know how to read data of the wav song and save it into the array... if i want to read...
11
3312
by: waffle.horn | last post by:
Hi, if this makes sense i want to create a function that can be called so that it reads a single line from a file, then after using the information destroys it. Such that when the function is...
6
32846
by: Thomas Kowalski | last post by:
Hi, currently I am reading a huge (about 10-100 MB) text-file line by line using fstreams and getline. I wonder whether there is a faster way to read a file line by line (with std::string line)....
9
7366
by: flebber | last post by:
I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b") and write it out . the compressed "*.k3b" file has two file and the one I was trying...
6
3716
by: Sean Davis | last post by:
I have a large file that I would like to transform and then feed to a function (psycopg2 copy_from) that expects a file-like object (needs read and readline methods). I have a class like so: ...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.