I have string of tuples
LL = [ ("text1",2,3,N/A), ("text2",N/A,5,6),("text3",N/A,5,N/A) ]
I need
LL = [ ("text1",2,3,-1), ("text2",-1,5,6), ("text2",-1,5,-1) ]
So simply remove N/A replace with -1. Do I need to read all lines? Data download shows N/A, its not a variable.
LL is string
Using ("text2",N/A,5,6).
Running python type on [0] is 'str'.
Running python type on [1] , i get no output.
If I split the line above as a, b,c,d, Since I want number not a N/A, is there a way to say if not number replace with a number (-1). WHILE SPLITTING each line. Or, if error replace with -1.
Here is another link with the same problem, notice [1] has a N/A. http://download.finance.yahoo.com/d/quotes.csv?s=GS&f=sb6vt1&e=.csv
After struggling with data download with ill tempered CSV fields. How could use try/Except format.
try:
IF XXX or YYY or ZZZ or AAA == 'N/A',
(dont process data...skip to except and pass)
except:
pass
N/A? Do you mean"N/A"?N/Aa string? What you have now is not valid Python syntax unless you are dividing a valueNbyA.N/A, unless you define two variablesNandAas numbers (or something overloading__div__in a weird way).confusion-of-ideatag.