Commit e093713a by serpucga

Bugfix: was writing the metadata instead of the header at the beggining of each file

parent 3cab07f8
...@@ -88,6 +88,7 @@ def increase_metadata_count( ...@@ -88,6 +88,7 @@ def increase_metadata_count(
def create_tweet_output_path( def create_tweet_output_path(
header: str,
tweet: dict, tweet: dict,
output_dir: str)\ output_dir: str)\
-> str: -> str:
...@@ -108,10 +109,8 @@ def create_tweet_output_path( ...@@ -108,10 +109,8 @@ def create_tweet_output_path(
# If the CSV file didn't already exist, initialize it with a header # If the CSV file didn't already exist, initialize it with a header
if os.path.isfile(tweet_output_file) is False: if os.path.isfile(tweet_output_file) is False:
with open(os.path.join(output_dir, ".metadata.json")) as f:
header = f.readline().strip()
with open(tweet_output_file, "w") as fw: with open(tweet_output_file, "w") as fw:
fw.write(header) fw.write(header.strip())
add_newfile_to_metadata( add_newfile_to_metadata(
tweet_output_file, tweet_output_file,
os.path.join(collection_path, ".metadata.json")) os.path.join(collection_path, ".metadata.json"))
......
...@@ -46,7 +46,7 @@ if __name__ == "__main__": ...@@ -46,7 +46,7 @@ if __name__ == "__main__":
for tweet in tweets_page: for tweet in tweets_page:
# Get output path and contents for the new CSV file # Get output path and contents for the new CSV file
csv_tweet_output_path =\ csv_tweet_output_path =\
utils.create_tweet_output_path(tweet, output_dir) utils.create_tweet_output_path(header, tweet, output_dir)
csv_tweet_contents =\ csv_tweet_contents =\
"\n" + str(utils.convert_tweet_to_csv(header, tweet)) "\n" + str(utils.convert_tweet_to_csv(header, tweet))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment