Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -58,17 +58,20 @@ def fetch_articles(keyword, max_results=10):
|
|
58 |
def write_articles_to_csv(articles, filename="articles.csv"):
|
59 |
with open(filename, mode='w', newline='', encoding='utf-8') as file:
|
60 |
writer = csv.writer(file)
|
61 |
-
writer.writerow(['Authors', 'Year', 'Title', 'DOI', 'Abstract', 'Journal'])
|
62 |
for article in articles:
|
63 |
-
|
|
|
64 |
print(f"Articles written to {filename}: {len(articles)}")
|
65 |
|
66 |
-
def articles_to_csv_string(articles):
|
67 |
output = StringIO()
|
68 |
writer = csv.writer(output)
|
69 |
-
writer.writerow(['Authors', 'Year', 'Title', 'DOI', 'Abstract', 'Journal'])
|
|
|
70 |
for article in articles:
|
71 |
-
writer.writerow([article['Authors'], article['Year'], article['Title'], article['DOI'], article['Abstract'], article['Journal']])
|
|
|
72 |
output.seek(0)
|
73 |
return output.getvalue()
|
74 |
|
|
|
58 |
def write_articles_to_csv(articles, filename="articles.csv"):
|
59 |
with open(filename, mode='w', newline='', encoding='utf-8') as file:
|
60 |
writer = csv.writer(file)
|
61 |
+
writer.writerow(['', 'Authors', 'Year', 'Title', 'DOI', 'Abstract', 'Journal'])
|
62 |
for article in articles:
|
63 |
+
writer.writerow(['[]', article['Authors'], article['Year'], article['Title'], article['DOI'], article['Abstract'], article['Journal']])
|
64 |
+
|
65 |
print(f"Articles written to {filename}: {len(articles)}")
|
66 |
|
67 |
+
def articles_to_csv_string(articles):
|
68 |
output = StringIO()
|
69 |
writer = csv.writer(output)
|
70 |
+
# writer.writerow(['Authors', 'Year', 'Title', 'DOI', 'Abstract', 'Journal'])
|
71 |
+
writer.writerow(['Year', 'Title', 'Abstract, 'DOI'])
|
72 |
for article in articles:
|
73 |
+
# writer.writerow([article['Authors'], article['Year'], article['Title'], article['DOI'], article['Abstract'], article['Journal']])
|
74 |
+
writer.writerow([article['Year'], article['Title'], article['Abstract'], article['DOI']])
|
75 |
output.seek(0)
|
76 |
return output.getvalue()
|
77 |
|