Skip to content

Commit

Permalink
Adapting method saving data to the file
Browse files Browse the repository at this point in the history
  • Loading branch information
jpatacz committed Mar 16, 2022
1 parent 2776345 commit d4ceded
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions skillcorner/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ def _get_and_write_data_with_id(self, id, filepath, *, url, paginated_request, p
try:
with open(filepath, 'w') as file:
json.dump(data, file, indent=4)
except TypeError:
with open(filepath, 'wb') as file:
file.write(data)
except TypeError as ex:
if 'DataFrame' in str(ex):
import pandas as pd
data.to_csv(filepath)
else:
with open(filepath, 'wb') as file:
file.write(data)

0 comments on commit d4ceded

Please sign in to comment.