473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

how to start reading a file in line number 5?

13
i have a file(CSV) and the contents are:

Data A,,,,DATA B,,
,,7/12/2007,,,,7/12/2007
,,1:00,,,,1:00
NAME,REGION ID,Prices,,NAME,REGION ID,Prices
(RESOURCE ID),,(QUANTITY),,(RESOURCE ID),,(QUANTITY)

AORT,6,"4,153.40",,TRIBU,3,"4,153.40"
BIGTH,2,"4,067.08",,YLUJ,1,"4,056.45"
STRT,9,"4,067.08",,TSLO,8,"4,056.45"

Situation:
i want to store all of this strings to MySQL except for the bold ones.
how can i place my pointer in line number 5?

badly needed please help thanks.
Jul 24 '07 #1
2 1713
mwasif
802 Expert 512MB
Use fgetcsv() to read your csv file. It returns a signle line, in while loop you can check on which line number you are e.g.
[PHP]$row = 1;
$handle = fopen("test.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== false)
{
if($row<5) continue;
// do your stuff here

$row++;
}
fclose($handle);[/PHP]
Jul 24 '07 #2
pbmods
5,821 Expert 4TB
MySQL's LOAD DATA INFILE command has an option to IGNORE # LINES, if you decide to go that route.
Jul 24 '07 #3

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

Similar topics

3
by: Kangol kangoll | last post by:
hi, i've been trying to figure out how to make visual basic start extracting text at a certain line to when i tell it to stop. I am making trying to make a program where it extracts text from a...
2
by: Alexander Schmidt | last post by:
Hi, I am not very familiar with C++ programming, so before I do a dirty hack I ask for a more elegant solution (but only the usage of STL is allowed, no special libs). So I need to read a file...
6
by: ataanis | last post by:
Hi, Can anybody tell me , why if I change the second value in the read() function, I get an error message, I'm dealing here with a file, that has at least 240 caracters per line Private Sub...
12
by: Felix85 | last post by:
here is my method for reading in a file: static room room::file2Room(int rnum){ ostringstream filename; filename << "../gamefiles/rooms/" << rnum << ".room"; ifstream...
2
by: sani8888 | last post by:
Hi everybody I am a beginner with C++ programming. And I need some help. How can I start with this program *********** The program is using a text file of information as the source of the...
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
4
by: GeekBoy | last post by:
I am reading a file of numbers using for loops. The numbers are in a grid as follows: 8 36 14 11 31 17 22 23 17 8 9 33 23 32 18 39 23 25 9 38 14 38 4 22 18 11 31 19 16 17 9 32 25 8 1 23
9
by: Dameon99 | last post by:
Hi, I am writing a program that reads from a text file with the format of data being: 0010 0110 0111 0001 I need to read each number on each line seperately and thats all fine. however I...
4
by: nembo kid | last post by:
This function crashes when called from main. It should read int elements of a 2d array (mat) Each element is placed on a line. The first line (first element) is the numbers of rows. The...
4
by: dacuteangel04 | last post by:
ok what my program is suppost to do is open a file - Grades.txt and read each line the breaking the lines down w/ tokens so i may later average some numbers an example some of the lines from the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
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...
0
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...
1
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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...

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.