03-27-2002
text drivers for .txt and .csv files ??
As a newcomer to UNIX I need to know if there are .txt and .csx ODBC drivers available. I want to import some data and the UNIX tech which I am in contact with does not know much about UNIX!
He asked me to find out if these drivers existed or use a 'LOAD DATA INFILE' command, which is not too familiar to me since my background in databases is windows and Sybase SQL - which Mysql is based on, right?
I don't want to load the data right away, rather check for correct column orders, types, etc and then import at a later time.
UNIX, php and Mysql are very tough to get to work and take a lot of extra time. I could have done this in 2 seconds on a windows box.
Don't get me wrong, I hate anything Microsoft, but at least iHTML (which I use) is a lot better than PHP - no doubt in my mind AND Sybase is much more intuitive than MySQL - so I have to assume that UNIX is a lot more of a pain than Windows.
Any ideas about my import concern?
Pleas email me ::email removed:: since I very rarely go tho this site.
Thanks,
Noodles
Last edited by oombera; 02-13-2004 at 01:31 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
HI guys,
I have created a script to read 1 column in a csv file and then place it in text file.
However, when i checked out the text file, it is not in a column format...
Example:
CSV file contains
name,age
aa,11
bb,22
cc,33
After using awk to get first column
TXT file... (1 Reply)
Discussion started by: mdap
1 Replies
2. Shell Programming and Scripting
I have a large CSV files (e.g. 2 million records) and am hoping to do one of two things. I have been trying to use awk and sed but am a newbie and can't figure out how to get it to work. Any help you could offer would be greatly appreciated - I'm stuck trying to remove the colon and wildcards in... (6 Replies)
Discussion started by: metronomadic
6 Replies
3. Shell Programming and Scripting
Hi All
I am trying to combine columns from multiple text files into a single file using paste command but the record length being unequal in the different files the data is running over to the closest empty cell on the left. Please see below.
What can i do to resolve this ?
File 1 File... (15 Replies)
Discussion started by: venky_ibm
15 Replies
4. Shell Programming and Scripting
EDIT: My problems have been solved thanks to the help of bartus11 and pravin27
This code is just to help me learn. It serves no purpose other than that.
Here's a sample csv that I'm working with -
#listofpeeps.csv
Jackie Chan,1954,M
Chuck Norris,1930,M
Bruce Lee,1940,M
This code is... (13 Replies)
Discussion started by: chickeneaterguy
13 Replies
5. Shell Programming and Scripting
Hi,
I need to parse text, xml files to get the statistic numbers and prepare summary csv file.
What is the best way to parse these file and prepare csv file.
Any idea you have , please?
Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies
6. UNIX for Dummies Questions & Answers
:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux.
I am working in Linux terminal.
I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I need to create a .csv file from information that i have in two different tab delimited .txt file. I just want to select some of the columns of each .txt file and paste them into a .cvs file.
My files look like:
File 1
transcript_id Seq. Description Seq. Length ... (2 Replies)
Discussion started by: alisrpp
2 Replies
8. Windows & DOS: Issues & Discussions
so...
Lets assume I have a text file.
The text file contains multiple "#" symbols.
I want to replace all thos "#"s with a STRING using DOS/Batch
I want to add a certain TEXT to the end of each line.
How can I do this WITHOUT aid of sed, grep or anything linux related ? (1 Reply)
Discussion started by: pasc
1 Replies
9. Shell Programming and Scripting
hi
i need to extract lines from multiple files to a csv file.
for example, i have these 3 files
file1.txt
date:29dec1980
caller:91245824255
called:8127766
file2.txt
date:11apr2014
caller:9155584558
called:8115478
file3.txt
date:25jun2015
caller:445225552
called:8117485 (30 Replies)
Discussion started by: lp.descamps
30 Replies
10. Shell Programming and Scripting
Hi dears
i use bash shell
i have INPUT.txt
like this
number of columns different in one
some row have 12 , some 11 columns
see last column
INPUT.txt
CodeGender Age Grade Dialect Session Sentence Start End Length Phonemic Phonetic
63 M 27 BS/BA TEHRANI 3 4 298320 310050... (2 Replies)
Discussion started by: alii
2 Replies
LEARN ABOUT PHP
mysqli_set_local_infile_handler
MYSQLI_SET_LOCAL_INFILE_HANDLER(3) 1 MYSQLI_SET_LOCAL_INFILE_HANDLER(3)
mysqli::set_local_infile_handler - Set callback function for LOAD DATA LOCAL INFILE command
Object oriented style
SYNOPSIS
bool mysqli::set_local_infile_handler (mysqli $link, callable $read_func)
DESCRIPTION
Procedural style
bool mysqli_set_local_infile_handler (mysqli $link, callable $read_func)
Set callback function for LOAD DATA LOCAL INFILE command
The callbacks task is to read input from the file specified in the LOAD DATA LOCAL INFILE and to reformat it into the format understood by
LOAD DATA INFILE.
The returned data needs to match the format specified in the LOAD DATA
PARAMETERS
o $
link -Procedural style only: A link identifier returned by mysqli_connect(3) or mysqli_init(3)
o $read_func
- A callback function or object method taking the following parameters:
o $stream
-A PHP stream associated with the SQL commands INFILE
o $&buffer
-A string buffer to store the rewritten input into
o $buflen
-The maximum number of characters to be stored in the buffer
o $&errormsg
-If an error occurs you can store an error message in here
The callback function should return the number of characters stored in the $buffer or a negative value if an error occurred.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
mysqli::set_local_infile_handler example
Object oriented style
<?php
$db = mysqli_init();
$db->real_connect("localhost","root","","test");
function callme($stream, &$buffer, $buflen, &$errmsg)
{
$buffer = fgets($stream);
echo $buffer;
// convert to upper case and replace "," delimiter with [TAB]
$buffer = strtoupper(str_replace(",", " ", $buffer));
return strlen($buffer);
}
echo "Input:
";
$db->set_local_infile_handler("callme");
$db->query("LOAD DATA LOCAL INFILE 'input.txt' INTO TABLE t1");
$db->set_local_infile_default();
$res = $db->query("SELECT * FROM t1");
echo "
Result:
";
while ($row = $res->fetch_assoc()) {
echo join(",", $row)."
";
}
?>
Procedural style
<?php
$db = mysqli_init();
mysqli_real_connect($db, "localhost","root","","test");
function callme($stream, &$buffer, $buflen, &$errmsg)
{
$buffer = fgets($stream);
echo $buffer;
// convert to upper case and replace "," delimiter with [TAB]
$buffer = strtoupper(str_replace(",", " ", $buffer));
return strlen($buffer);
}
echo "Input:
";
mysqli_set_local_infile_handler($db, "callme");
mysqli_query($db, "LOAD DATA LOCAL INFILE 'input.txt' INTO TABLE t1");
mysqli_set_local_infile_default($db);
$res = mysqli_query($db, "SELECT * FROM t1");
echo "
Result:
";
while ($row = mysqli_fetch_assoc($res)) {
echo join(",", $row)."
";
}
?>
The above examples will output:
Input:
23,foo
42,bar
Output:
23,FOO
42,BAR
SEE ALSO
mysqli_set_local_infile_default(3).
PHP Documentation Group MYSQLI_SET_LOCAL_INFILE_HANDLER(3)