Hi Merlem and all the other folks!
Ok, so this is as far as I am.
Your script is cutting the list to the right pieces. Only the naming of the files is not quite right yet. I sort of need "518a", "518b", "519a", "519b".....
Since I do realize that this might be a bit too challenging for a newbie, I would really like to ask some Questions:
thanks - I will check on that.
Via PyCharm settings it only shows me python 2.7 (not selected) and python 3.5 (selected) but im sure ill make it work if I try on!
Thank you - I will test the script and will give you feedback on how its working!
PyCharm seems to be working with Anaconda (python 3.6) now.
On your script it gives me:
Ok, so this is as far as I am.
Your script is cutting the list to the right pieces. Only the naming of the files is not quite right yet. I sort of need "518a", "518b", "519a", "519b".....
Since I do realize that this might be a bit too challenging for a newbie, I would really like to ask some Questions:
import csv f = open("/home/herbert/PycharmProjects/2017-02-10 CutList/Kastanie_Jahrringe.csv") csv_f = csv.reader(f, delimiter=';') firstlinedone = False <= why this? Probably starting parameter, right? listoffiles = [] <= make a empty list of files, right? for line in csv_f: <= cycle through every value of the csv # for the first line, make all files <= how to get 1a, 1b, 2a, 2b, 3a, 3b etc. maybe a List with two objects a and b? if firstlinedone == False: <= as long as the first line goes on keep going for columnumber, column in enumerate(line): <= now you're loosing me: columnnumber AND column? And enumerate = count lines? newfilename = "Baumprobe" + str(columnumber) + ".csv" <= now im on the road again... I like this stuff # one can also do more formatting here for the filename newfile = open(newfilename, "w") <= open new files in mode write which means create files listoffiles.append(newfile) <= always append the next new file to listoffiles firstlinedone == True <= if however, you are done with the first line, then: for columnumber, column in enumerate(line): <= still not getting this line csvwriter = csv.writer(listoffiles[columnumber], delimiter=',') <= i "sort of" get this, but not in detail: define csvwriter as a method which takes the columns and cuts them by delimiter? csvwriter.writerow([line[0], line[columnumber]]) <= why now write again? for anyfile in listoffiles: <= go through all the objects in listoffiles and close them anyfile.close() f.close() <= close all functions [color=#a9b7c6][font=Source Code Pro][/font][/color]
(Feb-16-2017, 11:03 AM)buran Wrote: Check PyCharm settings - that the project is set up to use the correct interpreter (the one with pandas installed). Linux comes with Python pre-installed and if you installed also Anaconda, I would assume you have at least 2 (and most probably 3) Python installations
Also, my other snippet does not use pandas, just the csv module.
thanks - I will check on that.
Via PyCharm settings it only shows me python 2.7 (not selected) and python 3.5 (selected) but im sure ill make it work if I try on!
(Feb-16-2017, 11:03 AM)buran Wrote: Also, my other snippet does not use pandas, just the csv module.
Thank you - I will test the script and will give you feedback on how its working!
PyCharm seems to be working with Anaconda (python 3.6) now.
On your script it gives me:
Error:Traceback (most recent call last):
File "/home/herbert/Pycharm_Projekte/2017-02-10 CutList/CutList_Buran.py", line 5, in <module>
filenames = zip(csv_f.fieldnames, 'ab' * (len(csv_f.fieldnames) / 2))
TypeError: can't multiply sequence by non-int of type 'float'
Im guessing python does'nt like float as a result of len/2.....?