explode "x,y","a,b","m,n" (Documentation Bugs and Problems)

by DickStomp ⌂ @, Europe Netherlands Sassenheim, Monday, October 06, 2014, 20:01 (936 days ago)

How to explode a CSV as "x,y","a,b","m,n" delimited by comma giving
field$[1] = "x,y"
field$[2] = "a,b"
field$[3] = "m,n"
as we have no directive "text delimiters are chr(34)"...
Sincerely,
Dick

--
it must be possible...

explode "x,y","a,b","m,n"

by DickStomp ⌂ @, Europe Netherlands Sassenheim, Tuesday, October 07, 2014, 20:33 (935 days ago) @ DickStomp
edited by DickStomp, Tuesday, October 07, 2014, 20:39

Download records of the banks are using this format.
Looking at LibreOffice I found solutions:
1) using LibreOffice, with chr(34) as text-delimiter switched ON, generates a new file with embedded commas between two "double-quotes" (like MSAccess)
2) using Basic256 explode on ","; second routine searching for strings without chr(34) on the end and adding next field to that; otherwise doing nothing than giving output
3) using Basic256 scanning for chr(34)+","+chr(34) and exploding on that combination

I'm still looking for the best solution...

PS I'm back in the sixties with COBOL,I like it...!

--
it must be possible...

explode "x,y","a,b","m,n"

by DickStomp ⌂ @, Europe Netherlands Sassenheim, Wednesday, October 08, 2014, 15:16 (934 days ago) @ DickStomp

#FIXED!! explode-bank.kbs

# processing bank records
# repair of inserted commas in a string, which is unstringed bij commas
# converting amount$ to signed using debcred$

name$ = "Name"
account$ = "123456789"
amount$ = "1234,56"
debcred$ = "D"
reason$ = "reason, you know"
address$ = "myaddress city"

# construct a bank record
bank$ = chr(34)+name$+chr(34)+","+chr(34)+account$+chr(34)+","
bank$ = bank$ +chr(34)+amount$+chr(34)+","+chr(34)+debcred$+chr(34)+","
bank$ = bank$ +chr(34)+reason$+chr(34)+","+chr(34)+address$+chr(34)

print "show bank-record"
print bank$

print "show work of explode an CSV-record"
field$ = explode(bank$, ",")
tmax = field$[?] -1
for t = 0 to tmax
print t+" "+field$[t]
next t
# sign amount
if mid(field$[4], 2, 1) = "D" then
L = length(field$[2])
field$[2] = chr(34) +"-"+ mid(field$[2], 2, L-1)
# shift left
for t = 4 to tmax-1
field$[t] = field$[t+1]
next t
tmax = tmax - 1
end if

print "repair hidden error commas"
dim new$(tmax)
new = 0
old = 0
for old = 0 to tmax
new$[new] = field$[old]
if right(field$[old],1) <> chr(34) then
new$[new] = new$[new] +","+ field$[old+1]
old = old + 1
tmax = tmax -1
end if
new = new + 1
next old

print "show new result"
for t = 0 to new-1
print t+" "+new$[t]
next t
end

--
it must be possible...

explode "x,y","a,b","m,n"

by Jim ⌂ @, Russell, KY, Thursday, October 09, 2014, 14:42 (933 days ago) @ DickStomp

Been covered up with school. Thought I would post how I would do it (maybe).

name$ = "Name"
account$ = "123456789"
amount$ = "1234,56"
debcred$ = "D"
reason$ = "reason, you know"
address$ = "myaddress city"

# construct a bank record
bank$ = chr(34)+name$+chr(34)+","+chr(34)+account$+chr(34)+","
bank$ = bank$ +chr(34)+amount$+chr(34)+","+chr(34)+debcred$+chr(34)+","
bank$ = bank$ +chr(34)+reason$+chr(34)+","+chr(34)+address$+chr(34)

#### simple down and dirty
#### ASSUMES THAT ALL FIELDS HAVE QUOTE MARKS
####
stuff$ = mid(bank$,2,length(bank$)-2) # strip quotes off of end
stuff$ = explode(stuff$,'","')
for t = 0 to stuff$[?]-1
print t + " " + stuff$[t]
next t

Avatar

explode "x,y","a,b","m,n"

by DickStomp2 @, NL- SASSENHEIM, Thursday, October 09, 2014, 20:53 (933 days ago) @ Jim

explode (stuff$, '","')
gives an error even with (stuff$, "","")
according to your documentation

Indeed the dirty way, but not effective
There is a conversion within LibreOffice Calc that that strange format rebuilds; unstring on comma with respect to pairs of chr(64)! Excellent.

Better is to wait for the new SWIFT record layouts MT940 and MT942
They will be obliged as from 2015-01-01
I expect that a lot of amateur stuff from the past is corrected...
Quotation marks as text delimiter, that's old...

Avatar

explode "x,y","a,b","m,n"

by DickStomp2 @, NL- SASSENHEIM, Friday, October 10, 2014, 13:02 (932 days ago) @ DickStomp2

after downloading version 1.1 from the Consortium everything runs fine!
Dick

RSS Feed of thread
powered by my little forum