BigThonkers / ThonkTools

Revolutionary wrappers for stupid lab stuff.
1 stars 3 forks source link

Extended CSV Reader #12

Closed munnich closed 5 years ago

munnich commented 5 years ago

Idea from V88 to remove empty items from csvreader's output. Erik's code:


def txttoarr(fname, remove_last = False, offset = 4, *kwargs):
    import numpy as np
    with open (fname, 'r') as myfile:
        data = myfile.read().replace(',', '.').replace('\n', ',').replace('  ', ',').replace("\t",",")
    datarray = data.split(',')
    output = []
    for item in datarray:
        if item != '':
            output.append((item))
    internal = []
    for item in output[offset:]:
        internal.append(float(item))

    output =(internal)
    x = output[0::2]
    y = output[1::2]
    return [x,y]
munnich commented 5 years ago

This is quite similar to the V81 issue, so I'm closing this for now.