May 17, 2026, 11:40 PM
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import json
|
||||
import pandas as pd
|
||||
|
||||
# Wczytanie danych JSON z pliku
|
||||
with open('2dane.json', 'r', encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
|
||||
# Przygotowanie danych do tabeli
|
||||
rows = []
|
||||
for category in data['categories']:
|
||||
for keyword in category['keywords']:
|
||||
for source in keyword['top_sources']:
|
||||
rows.append({
|
||||
'Category': category['category'],
|
||||
'CategorySummary': category['category_summary'],
|
||||
'Keyword': keyword['keyword'],
|
||||
'Summary': keyword['summary'],
|
||||
'Trending': keyword['trending'],
|
||||
'Source': source['source'],
|
||||
'Text': source['text'],
|
||||
'URL': source['url']
|
||||
})
|
||||
|
||||
# Konwersja na DataFrame Pandas
|
||||
df = pd.DataFrame(rows)
|
||||
|
||||
# Wyświetlenie tabeli
|
||||
print(df)
|
||||
|
||||
# Zapisanie tabeli do pliku CSV (opcjonalnie)
|
||||
df.to_csv('tabela.csv', index=False, encoding='utf-8')
|
||||
Reference in New Issue
Block a user