473,407 Members | 2,314 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,407 software developers and data experts.

read from file with delimiters

How do I read data from file with delimiters (for instance A;B;ccc;S45A;UU)?
I'd like to write that data to MYSQL table...

Thanks for the help,
Boris Savc
Jul 17 '05 #1
3 2198
"Boris ©avc" <bo********@odis-info.com> wrote:
How do I read data from file with delimiters (for instance
A;B;ccc;S45A;UU)? I'd like to write that data to MYSQL table...


Please don't multipost!

PHP:
Have a look into fgetcsv():
http://uk.php.net/manual/en/function.fgetcsv.php

MySQL:
Have a look into LOAD DATA INFILE:
http://www.mysql.com/doc/en/LOAD_DATA.html

HTH;
JOn
Jul 17 '05 #2
Boris ©avc wrote:
How do I read data from file with delimiters (for instance A;B;ccc;S45A;UU)?


http://www.php.net/manual/en/function.fgetcsv.php

--
Jock
Jul 17 '05 #3
Pć Tue, 24 Feb 2004 11:27:58 +0100, skrev Boris ©avc
<bo********@odis-info.com>:
How do I read data from file with delimiters (for instance
A;B;ccc;S45A;UU)?
I'd like to write that data to MYSQL table...


This is -one- way of doing it:

$lines = array(); //Create an array.
$lines = file("my_delimed_data_file.dat");//Load the lines into the array.
foreach($lines as $line) { //Loop through the array.
list($field1,$field2,$field3,$field4,$field5) = explode(";",$line);
//Extract your vars from the line.
mysql_query("INSERT INTO your_table ('field1',___,'field5')
VALUES(".$field1.",___,".$field5.")"); //Insert them into the db.
}//End of loop

The ___ part is of course just "fill in the blanks yourself".
The code is of course not complete, but you get the general idea.
--
Fred H

void FredH::Contact() {
TextToSpeach.say("frode at age dee dee dot en oh");
}
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jong Choi | last post by:
Dear All, I am trying to open the file(walk5.dat) and then read the data The structures of data are 0, 0, -10, -10, 0, -8.1,-12,-10 , 0,-14,-10,-7,0, 6.096666667,-10,-10,1, ...
2
by: les_ander | last post by:
Hi, matlab has a useful function called "textread" which I am trying to reproduce in python. two inputs: filename, format (%s for string, %d for integers, etc and arbitary delimiters) ...
75
by: Greg McIntyre | last post by:
I have a Python snippet: f = open("blah.txt", "r") while True: c = f.read(1) if c == '': break # EOF # ... work on c Is some way to make this code more compact and simple? It's a bit...
39
by: Timex | last post by:
I want to delete all comments in .c file. Size of .c file is very big. Any good idea to do this? Please show me example code.
14
by: spike | last post by:
Im trying to write a program that should read through a binary file searching for the character sequence "\name\" Then it should read the characters following the "\name\" sequence until a NULL...
2
by: Profetas | last post by:
I have the following code that detects a <c> and </c> #include <stdio.h> main(int argc, char *argv) { FILE* fp; char data;
8
by: H | last post by:
Now, I'm here with another newbie question .... I want to read a text file, string by string (to do some things with some words etc etc), but I can't seem to find a way to do this String by...
3
by: Ray | last post by:
Hello World, I made a Windowsform that reads data from a CSV file. It works fine, but when I have read the data of a record I have to re-Debug the form to read another record. So when I put a...
1
by: pencoder | last post by:
Actually i wrote C# codings to read text between delimiters.it works nicely. in my codings i have a condition it checks whether the delimiter indexed first time or the second time.based on that i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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...
0
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...

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.