Sponsored Content
Top Forums UNIX for Dummies Questions & Answers text drivers for .txt and .csv files ?? Post 18501 by LivinFree on Friday 29th of March 2002 12:47:26 AM
Old 03-29-2002
I may be way off, but you don't need a driver just to read a csv (tsv, *sv) file into data structures.
Use awk, sh, perl.... etc.
For example, each night we produce a very large comma-delimited file each night for importation into a legacy application.
This will check if the file is 120 columns wide. If not, it will identify which row produced the error, and if so, will give us the output of column 52 along with the record identifier, which we can use for reporting purposes:
Code:
BEGIN { FS = "," }
{
   if (NF != 120)
      printf("Bad: %s\n",$1)
   else
      printf("%s %s\n",$1, $52)
}

If it's OK, it's imported into a legacy database.

And I don't know where you are coming up with the information that MySql is derived from SyBase in any way... That would be like saying that Oracle was built on db2.
Please check your sources, as you may have been misinformed.

Like was said above in another post, we are afraid of (and do not understand the full feature-set of) any product that we are not familiar with. I suggest that if you're really going to use these tool, learn them fully before poo-pooing them.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

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

Sed or awk script to remove text / or perform calculations from large CSV files

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

Combine Multiple text or csv files column-wise

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

Comparing Strings in 2 .csv/txt files?

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

Parsing txt, xml files and preparing csv file

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

Need help combining txt files w/ multiple lines into csv single cell - also need data merge

: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

How to create a .csv file from 2 different .txt files?

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

2 Questions: replace text in txt file, add text to end of txt file

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

Read multiple text files and copy data to csv

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

Search last column of INPUT.txt in TABLEs text and add correspond columns to INPUT.txt

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
MAXDB_FETCH_ARRAY(3)							 1						      MAXDB_FETCH_ARRAY(3)

maxdb_fetch_array - Fetch a result row as an associative, a numeric array, or both

       Procedural style

SYNOPSIS
mixed maxdb_fetch_array (resource $result, [int $resulttype]) DESCRIPTION
Object oriented style mixed maxdb_result::fetch_array ([int $resulttype]) Returns an array that corresponds to the fetched row or NULL if there are no more rows for the resultset represented by the $result param- eter. maxdb_fetch_array(3) is an extended version of the maxdb_fetch_row(3) function. In addition to storing the data in the numeric indices of the result array, the maxdb_fetch_array(3) function can also store the data in associative indices, using the field names of the result set as keys. Note Field names returned by this function are case-sensitive. Note This function sets NULL fields to the PHP NULL value. If two or more columns of the result have the same field names, the last column will take precedence and overwrite the earlier data. In order to access multiple columns with the same name, the numerically indexed version of the row must be used. The optional second argument $resulttype is a constant indicating what type of array should be produced from the current row data. The possible values for this parameter are the constants MAXDB_ASSOC, MAXDB_ASSOC_UPPER, MAXDB_ASSOC_LOWER, MAXDB_NUM, or MAXDB_BOTH. By default the maxdb_fetch_array(3) function will assume MAXDB_BOTH, which is a combination of MAXDB_NUM and MAXDB_ASSOC for this parameter. By using the MAXDB_ASSOC constant this function will behave identically to the maxdb_fetch_assoc(3), while MAXDB_NUM will behave identi- cally to the maxdb_fetch_row(3) function. The final option MAXDB_BOTH will create a single array with the attributes of both. By using the MAXDB_ASSOC_UPPER constant, the behaviour of this function is identical to the use of MAXDB_ASSOC except the array index of a column is the fieldname in upper case. By using the MAXDB_ASSOC_LOWER constant, the behaviour of this function is identical to the use of MAXDB_ASSOC except the array index of a column is the fieldname in lower case. RETURN VALUES
Returns an array that corresponds to the fetched row or NULL if there are no more rows in resultset. EXAMPLES
Example #1 Object oriented style <?php $maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } $query = "SELECT name, state FROM hotel.city ORDER by zip"; $result = $maxdb->query($query); /* numeric array */ $row = $result->fetch_array(MAXDB_NUM); printf ("%s (%s) ", $row[0], $row[1]); /* associative array */ $row = $result->fetch_array(MAXDB_ASSOC); printf ("%s (%s) ", $row["NAME"], $row["STATE"]); /* associative and numeric array */ $row = $result->fetch_array(MAXDB_BOTH); printf ("%s (%s) ", $row[0], $row["STATE"]); /* free result set */ $result->close(); /* close connection */ $maxdb->close(); ?> Example #2 Procedural style <?php $link = maxdb_connect("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } $query = "SELECT name, state FROM hotel.city ORDER by zip"; $result = maxdb_query($link, $query); /* numeric array */ $row = maxdb_fetch_array($result, MAXDB_NUM); printf ("%s (%s) ", $row[0], $row[1]); /* associative array */ $row = maxdb_fetch_array($result, MAXDB_ASSOC); printf ("%s (%s) ", $row["NAME"], $row["STATE"]); /* associative and numeric array */ $row = maxdb_fetch_array($result, MAXDB_BOTH); printf ("%s (%s) ", $row[0], $row["STATE"]); /* free result set */ maxdb_free_result($result); /* close connection */ maxdb_close($link); ?> The above example will output something similar to: New York (NY) New York (NY) Long Island (NY) SEE ALSO
maxdb_fetch_assoc(3), maxdb_fetch_row(3), maxdb_fetch_resource(3). PHP Documentation Group MAXDB_FETCH_ARRAY(3)
All times are GMT -4. The time now is 07:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy