473,216 Members | 2,074 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,216 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 2188
"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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.