Master:
# 1    commas problem in csv file creating                  
webfun
Online no
State
Grouping Member
Class class4
Score 156
Wealth 123
Posts 102
Login 03:47:39
I use commas as delimeter for csv file, how to escape the commas in the content? i found it fails to open my design csv file with excel
Hits: 461, Date: 2010-03-07 03:00:15
[Agree] ( 4 ) [Against] ( 8 )

# 2    you may need to normalise the csv content                  
Dude
Online no
State
Grouping Member
Class class4
Score 161
Wealth 125.5
Posts 116
Login 00:20:49
Every field must by quoted, then escape double quote and commas, for example:

"field1\,yes","field\"good one\""

, is escaped by \, " is escaped by "
Hits: 458, Date: 2010-03-07 04:48:20
[Agree] ( 4 ) [Against] ( 10 )

# 3    Dude, it is not right                  
hans
Online no
State
Grouping Member
Class class4
Score 221
Wealth 155.5
Posts 156
Login 21:17:46
don't need escape commas if you use double quote. For example:
"test,test2","test","test say:""good"", yes"

Luke's sample is not right too, " is escape by " not \
Hits: 453, Date: 2010-03-13 23:51:50
[Agree] ( 4 ) [Against] ( 9 )

# 4    i got a large csv file, i useed this rule, but failed to display                  
hans
Online no
State
Grouping Member
Class class4
Score 221
Wealth 155.5
Posts 156
Login 21:17:46
maybe there are some other symbols preventing it displays properly?
Hits: 452, Date: 2010-03-13 23:53:19
[Agree] ( 4 ) [Against] ( 9 )

# 5    My understanding of CSV                  
exp
Online no
State
Grouping Member
Class class4
Score 348
Wealth 219
Posts 269
Login 11:49:09
In # 3, hans' example
, is a delimeter
" is a qualifier

You can define different delimeter and qualifier actually, but you must following the following rule:

You must use qualifier if the content of colunms contains a symbol that is the same as the delimeter, for example, two columns csv: "yes,text,hi","good,netspec"

You must use the symbol of qualifier to escape the content of colunms contains a symbol that is the same as the qualifier. For example, ""hi, how are you"" in a column.

Normally we use , as a delimeter and " as a qualifier.
Hits: 448, Date: 2010-03-14 23:32:49
[Agree] ( 4 ) [Against] ( 6 )

# 6    There is a Java library called readcsv                  
exp
Online no
State
Grouping Member
Class class4
Score 348
Wealth 219
Posts 269
Login 11:49:09
You can download the jar file, and include it in a external libary of build path if you use eclipse.

I know it is easy to write csv by yourself, but this library is quite smart, it is easy to write csv and read csv.
Hits: 447, Date: 2010-03-14 23:37:13
[Agree] ( 4 ) [Against] ( 6 )

1 - 6 [ 6]

Reply: commas problem in csv file creating

*First line:


More content:


Tags:



Hint: You cannot post here before loginLogin | Register

nothing