An extra column is added when getting items in a folder (Python)
I am creating two different lists from a data frame and then exporting those to a csv file. When I indicate what columns I want, it works fine when printing the list. But when appending to a dataframe, an extra column 'etag' is added.
for b in box_folders:
folder_items = user_client.folder(folder_id=b).get_items(fields=('type','id','name'))
for item in folder_items:
if item.type == 'folder':
# print(f'Appending {item.name} to folder_list . . .')
folder_list.append(item) # create a list of folders
else :
pass
# if item.type == 'file'
# print(f'Appending {item.name} to file_list . . .')
# file_list.append(item)
# # create a dataframe for folder list
df_folders = pd.DataFrame(data = folder_list, columns=['type', 'id','etag', 'name'])
Results:
folder_list
[<Box Folder - 137845028492 (north)>,
<Box Folder - 137845191876 (south)>,
<Box Folder - 137175604050 (Bullitt_2009_aerial)>,
<Box Folder - 137849896344 (30metanorth)>,
<Box Folder - 137849654596 (30metasouth)>,
<Box Folder - 137850072121 (DEM30FT_N)>,
<Box Folder - 137849524642 (DEM30FT_S)>,
<Box Folder - 137850575392 (Meta_N)>,
<Box Folder - 1378505
df_folders
type id etag name
0 type id etag name
1 type id etag name
2 type id etag name
3 type id etag name
4 type id etag name
.. ... .. ... ...
227 type id etag name
228 type id etag name
229 type id etag name
230 type id etag name
231 type id etag name
[232 rows x 4 columns]
file_list
[]
df_files
Empty DataFrame
Columns: []
I know it's probably simply just to write the list to csv, but what is going on here?
-
correction,
df_folders should look like this
er - 141542702314 (US_Topo_2016_TIF)>]
df_folders
type id etag name
0 type id etag name
1 type id etag name
2 type id etag name
3 type id etag name
4 type id etag name
.. ... .. ... ...
227 type id etag name
228 type id etag name
229 type id etag name
230 type id etag name
231 type id etag name
Please sign in to leave a comment.
Comments
2 comments