pplatek / bafprp

Automatically exported from code.google.com/p/bafprp
0 stars 0 forks source link

Add delimiter escaping for special characters in record information #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Fields such as CountryCode and ICINCID contain commas in the text 
output.  This confuses systems that read using a CSV format.

Workaround is to change the delimiter to a different character, but this 
means you must change setting in other softare used to read the files - 
such as MS Excel, and database products.

Just a FYI

Original issue reported on code.google.com by bge...@gmail.com on 16 Nov 2009 at 8:16

GoogleCodeExporter commented 9 years ago
In order to contine using the comma for the CSV file, I tried to suppress the 
text 
portion of the offending fields using the -pt or -pf command, but I must not 
understand the correct usage as the output remained unchanged.  

bafprp  -pticincid:number_only -ptcountrycode:number_only -
ptphonenumber:hyphens:false -rcsv -prfilename:record.csv -prdelimiter:, -
plfilename:logs.csv -pldelimiter:, -pefilename:errors.csv -pedelimiter:, -
prfields:type,calltype,originatingnpa,originatingnumber,terminatingnpa,terminati
ngnum
ber,elapsedtime,date,time,filename,calledpartyanswerindicator,filepos,circuittim
e,tru
nkgroupnumber,numberidentity,largedigits,countrycode,lrn,icincid -d 900*

Original comment by bge...@gmail.com on 16 Nov 2009 at 11:17

GoogleCodeExporter commented 9 years ago
Good point, for the moment I changed the default delimiter to ';'
number_only only works for the number switch data type.  Its an interesting 
idea to
print the switch value instead of the string value, but its also mostly useless 
as
the only way to find out what the numbers mean is to look in the program or at 
the
document format..

I might be able work in some kind of escape character solution for csv output, 
but
since it works with a different delimiter i'll mark this low priority.

Original comment by charless...@gmail.com on 17 Nov 2009 at 5:41

GoogleCodeExporter commented 9 years ago
I think the CSV standard (http://www.rfc-editor.org/rfc/rfc4180.txt) is to 
simply
escape all strings that contain quotes, newlines, and delimiter characters by 
having
them in double quotes.  A lot of software simply surrounds all character fields 
with
quotes, but a bit of logic to decide if it should be done is helpful since that 
many
quotes can add length to the output.

I'll be using ";" until such time...  It can be used with every spreadsheet and 
every
script language's split method.

Original comment by th...@bendtel.net on 10 Dec 2009 at 10:22

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r237.

Original comment by charless...@gmail.com on 11 Mar 2013 at 2:01