writing list data to file ?

I did a test with a new file and don’t really get the right data in the file !

I get the following data

['10032 ', ’ Brown ', ’ ', ’ ', ’ Gloss min 80 ', ’ 473F3F
']
['10045 ', ’ Brown ', ’ ', ’ ', ’ Gloss min 80 ', ’ 5F5453
']

it is adding the
on the last list item ?

I did another file and that one works fine

so not certain why this file is not working !

how can I get rid of this
letters ?

thanks for any feedback

happy bl

Probably you are reading lines from a file, then you get a "
" at the end. You can cut that character off before splitting.

you right I need to modify a list from a file to add some fields then resave it

but how do you get rid of these /n thing?

if I print the value before I save it I don’t see this
thing!
also how come the
is added not at then end of the line but on last list item ?
how do you read line without taking in the
thing ?

I do need one list per line
and problem is that the first file I did
did not have list per line but only float list
and I need to modify the each line to add some new fields !
then save it so that I can change each line as a list with the brackets
then I can re use it in a py file and define all lines as a list of list
for data in a script !

thanks

If you don’t have to do this in Blender, maybe you should look at the Pandas library, which helps you to deal with data like what you are describing. There is also a csv module in the standard library.

If you have further problems, please post some code.

you can strip whitespace by calling line = line.strip()
or you can strip the last character ("
") off with line = line[:-1]

Also, this is the kind of question where google will help you more quickly. Stackoverflow is full of Python beginners’ questions like this.

got something on CSV but have to learn it more to understand it !
but will test that !

pandas never use that one before
will check it out

sometimes stack can help but lot’s of threads are very old and not for latest python!

thanks