How to add zero in a list between two comma

mrcx@yahoo.com's icon

Hello,

I'm aiming to work on a project using NASDAQ market data. I use REPLAY file from DAS Trader Pro software. I'm working on Tesla's stock tape data.

I've managed to decode the code used in the replay data file to a considerable extent. However, my issue lies in handling the data as a list. I've successfully separated each line, which is quite a basic manipulation.

But, I'm encountering difficulty in inserting "0" when there's no float value between the commas. For instance, from "dIA26,1,,,1," I would like to obtain "dIA26 1 0 0 1," and from "pFB46,,1,,.01" I aim to get "pFB46 0 1 0 0.01."

I'll include my current patch for reference.

Max Patch
Copy patch and select New From Clipboard in Max.

my text files is to big to attach but here a sample :

uFA14,4,,,.02
uFA14,4,,,.02
uFA14,4,,,.02
uFA14,1,,,.01
tIA14,1,,,16
uFA14,1,,,.99
uFA14,1,,,.01
zFq14,1,,,1
kFA14,1,,,.01
zFA14,1,,,.01
hF@14,1,3,,.01
pI@14,1,3,,1
uF@14,1,3,,.01
uF@14,1,3,,.01
uF@14,1,3,,.01
uF@14,1,3,,.01
k@q14,1,,,1
k@q14,1,,,1
k@q14,1,,,1
tIB14,,1,-1,1
tFA14,1,,1,.84
uF@14,1,3,,.84
zFp14,1,3,,1
k@q14,1,,,1
z@q14,1,,,1
tFA14,1,,,.88
uFA14,1,,,.12
kFq14,1,,,1
zFA14,1,,,.02
d@p14,.5,.5,-0.5,1
tFA14,1,,.5,.11
uFA14,1,,,.01
zFA14,1,,,.98
kFq14,1,,,2
dIA14,1,,,1
dI@14,.88,.12,-0.12,20

Thank you for any suggestions!

Source Audio's icon

Replacing all commas with "0 " won't do,
but the question is: is there really any string that ends with comma
that needs to be preserved ?

Not in that posted list, but yes in that few examples where
you say :
For instance, from
"dIA26,1,,,1," I would like to obtain "dIA26 1 0 0 1,"
and from "pFB46,,1,,.01" I aim to get "pFB46 0 1 0 0.01."

First one ends with comma, the other with period,
but even if that is not the case, replacing all commas with "0 "
will give you wrong result.
in fact you need to replace single commas which seem to be value separators with spaces and replace remaining ones with space separated zeros.
for example if string is:
k@q14,1,,,1
result is
k@q14 1 0 0 1
1st comma after 14 gets replaced by space,
3 consecutive commas result in 2 space separed zeros.

this:
dI@14,.88,.12,-0.12,20
should result in:
dI@14 .88 .12 -0.12 20

in max .12 etc is auto converted to 0.12 if you convert symbol to list.

mrcx@yahoo.com's icon

Sorry, maybe a was not clear, english is not my first langage.

I need to insert (place something between) the value Zero between comma as

"1,,2" became "1 0 2".

Any idea?

Source Audio's icon

to insert would end in 1,,2 = 1,0,2
you want to replace 2 commas with a zero,
3 commas wih 2 zeros etc.

This can not work using text output to message.
In max comma makes message iter it's parts between commas.

a, b, c

gets out as :
a
b
c

a,,,
gets out as

a
nothing else.
you must convert your text file before you read it into text.
If you don't know how to do that using some kind of text processing, it can aso be one in max usig filein.
I can put somthing togethr for you, but you have to tell me what is maximum number of expected repeated commas.
,,, 3 ? or more ?

mrcx@yahoo.com's icon

Thanks, I will do a quick script to convert the files.

By the way, do you thing it would have been possible to do that kind of manipulation in realtime with a js object?

Source Audio's icon

js - one can do that, but why bother if you can convert files from beginning
and use strings without anything in between