Solved

CSV vs Text delimited file

Posted on 2010-08-26
12
1,116 Views
Last Modified: 2012-05-10
In the case where data files are required to be gathered from different sites, then uploaded into a SQL Server database, which is better to use and why? CSV files or Text delimited files (with a pipe delimiter for example)?
0
Comment
Question by:DBADS
  • 3
  • 2
  • 2
  • +5
12 Comments
 
LVL 3

Expert Comment

by:sasi_kmr
ID: 33528850
csv file are for more better to manage data and format the data.

text files are not convenient to work with.

thanks.
$a$i
0
 
LVL 8

Accepted Solution

by:
kingjely earned 42 total points
ID: 33528876

Agreed, easy to work with the data in .csv format

Heres how to load the data in mysql

LOAD DATA INFILE
'Drive:/path/filename.csv'
INTO TABLE yourtable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n';

If you want to exclude the headings(the first line or lines)

EG:

LOAD DATA INFILE
'Drive:/path/filename.csv'
INTO TABLE yourtable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;

Kj
0
 

Author Comment

by:DBADS
ID: 33528921
But in what way is the CSV better than text files?
Would you please specify cases where CSV was better than Text?
0
 
LVL 11

Assisted Solution

by:tickett
tickett earned 42 total points
ID: 33528973
CSV is essentially a text file

I actually tend to use pipe delimited for my imports/exports these days as i find data is a lot less likely to contain pipes than contain commas, quotation marks etc (which potentially breaks the file!)

L
0
 
LVL 2

Assisted Solution

by:akramryk
akramryk earned 42 total points
ID: 33529004
CSV and other text format other tan XML have same processing time. In both cases databse search for delimiter to seperate field values.
There is one drawback in using CSV when your data columns has commas ","  then u get unexpected results. While in using other delimitters (like special cahracters as pype "I" sign ) you can avoid such errors.
0
 
LVL 8

Assisted Solution

by:infolurk
infolurk earned 42 total points
ID: 33529072
CSV stands for Comma Seperated value text file. They are easy to read in raw format, generally regarded as industry standard.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 8

Expert Comment

by:infolurk
ID: 33529080
CSV is a text file, the reason they are useful is because they are easily imported into multi column formats such as spreadsheets and databases.
0
 
LVL 23

Assisted Solution

by:adilkhan
adilkhan earned 41 total points
ID: 33529216
CSV or TXT file... its same thing.

CSV...
its easy to create CSV file, say if you want your application to generate a CSV file and would like Ms Excel to open it by default. as mentioned above problem is with extra "," in the column values. this coul dbe avoided by text text qualifers( " around text).

TXT

Same process time as CSV, only thing is it has .txt extension, and would need to imported into MS EXCEL.
0
 
LVL 11

Expert Comment

by:tickett
ID: 33529227
The extension is also not important. I often use .dat extension for my pipe delimited files.

Using text qualifiers doesn't always help in CSV (imagine i have a field which also contains those text qualifiers!

L
0
 
LVL 2

Assisted Solution

by:dirkvdo
dirkvdo earned 41 total points
ID: 33529364
@tickett : single character delimiters are indeed not always possible. Therefore, if I can (i.e. I scripted the creation of the file myself), I use a multi-character delimiter (usually something like %/µ). These files can also be read by Excel, but you need two steps more to import them (open the file with excel, select first column and perform "text to columns" action, using the multi-character delimiter you used ... et voilà).
With the instruction given by kingjely, you'll have to replace the ',' in the line
FIELDS TERMINATED BY ','
by something corresponding with the chosen multi-character delimiter.
0
 
LVL 11

Expert Comment

by:tickett
ID: 33529401
@dirkvdo: true- but you have to be careful opening the file with excel (it has a nasty habbit of "guessing" the file is .csv and automatically splitting columns. when you then do your "text-to-columns" operation your data gets a bit messed

but i expect we've covered what @sasi_kmr wanted to know :)

L
0
 

Author Closing Comment

by:DBADS
ID: 33552204
There was no decisive or recommended appraoch but the discussion is rich enough
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MS SQL Bulk load data error 5 34
Help with SQL Query 23 39
sql query Help 12 34
SQL - Join 2 Tables Based on Ranges 8 10
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now