I am new to Kaltura and use of API to get/put data.
I followed the Workflow guides in Kaltura Developer website and manage to search for entries like by filter.creatorIdEqual = “someone”, and is able to list the results which contains rows of records in dictionary format.
I have 3 questions:
-
How can I save the search results as a csv file? I tried to write the dictionary type search results to csv file using various methods but failed. Sample codes as follows.
-
How to overcome the limits in the no. of records returned in the search results. Currently, I only see the most 30 records returned in the search results but in actual fact there are more than 200 entries belonging to the creatorId.
-
Where can I find any information related to the filesize of an entry in Kaltura. I understand that an entry in Kaltura may have a few flavors, which with a different entryId. May I know where can I find out more about these flavors and their meta data like creation date and filesize.
Thank you.
Lay Kock
The python codes I used to save the search research are as follows.
Find entries by CreatorId
filter = KalturaMediaEntryFilter()
filter.creatorIdEqual = “someone”;
pager = KalturaFilterPager()
result = client.media.list(filter, pager)
for item in result.objects:
print(item.dict); # this yields the search results with 30 records in dictionary type successfully
Write results to a csv file using Import Pandas as Pd
for item in result.objects:
df = pd.DataFrame.from_dict(item.dict, orient=“index”)
df.to_csv(‘entries_file.csv’, header=False)
The line df = pd.DataFrame.from_dict(item.dict, orient=“index”) yields an error AttributeError: ‘str’ object has no attribute ‘items’
Write results to a csv file using Import csv
with open(‘filename.csv’, ‘w’) as csv_file:
writer = csv.write(csv_file)
for item in result.objects:
write.writerow(item.dict);
This only yields the column headings for each records
Note: item.dict should have 2 underscores before and after ‘dict’. Somehow, the WYSIWYG editor change it to a bolded dict.