It's me again with lots of cruises/campaigns, points and txt files but now I have additionally polygons to create.
This is my main script:
# Step 1: find the source files to process
list_of_files = FindFiles(location_for_tables)
# Step2: prozess each file to data for points
for each_file in list_of_files:
# create and save sub tables
# Step3: prozess each file to create a point in kivupoints
list_of_tables = FindFiles(DirOutTables)
for each_table in list_of_tables:
# create and store the point
tview = CreateTableView(DirOutTables, each_table)
pointInfo = ReadPointInfo(tview)
uid = LoadPointInfoToClass(pointInfo)
# Step4: select points per campaign and create a polygon
for each_campaign in list_of_files:
In Step2 and Step4 I am using the same files. But because I have to use the result from Step3 in Step4 I can't use the same for loop for Step2 and Step4. In both functions store_table(each_file) and CreatePolygonFromCampaign(each_campaign) I ask for the uniqueValues of one attribute of the current file. While this works perfectly with profile_nrs=unique_values(table, "Station") in the store_table(each_file) function (table receives the value from each_file), in the CreatePolygonFromCampaign(each_campaign) it tells me the correct file name but stops the script with the error message "cannot open 'KivuWatt_151120_Near-plant_CTM257 (2).txt'" (which is the correct txt file) while trying to retrieve the unique values for the Cruise attribute. I also tried other attributes and other files but with the same result.
I wonder if the file is somehow "blocked" by the first loop or the first uniqueValues() method since it's using a SearchCursor. But it's using a "with arcpy.da.SearchCursor(table, [field]) as cursor" so I would assume it should release/delete the cursors afterwards again...
Any help on this will be highly appreciated.
I think I provided all necessary information and script snippets but please let me know if you need more details.
Thanks in advance!