Skip to content
Snippets Groups Projects
Commit ffabaff6 authored by Piotrek's avatar Piotrek
Browse files

Feat: Added python code to write the json file with complete companies data to...

Feat: Added python code to write the json file with complete companies data to a collection in firebase
parent 1f338cc5
No related branches found
No related tags found
1 merge request!1Fix: Figured out the issue regarding ts not seeing chrome types + fixed...
File added
File deleted
......@@ -90,7 +90,7 @@
<div class="grid grid-cols-2 shadow-sm p-2 bg-green-50 rounded-t-xl">
<div class="flex gap-2 items-center">
<img class="w-6 h-6" src={logo} alt="Leaf logo" />
<h1 class="text-2xl font-bold logo">Leaf</h1>
<h1 class="text-xl font-bold logo">Leaf</h1>
</div>
<div class="justify-self-end mr-3 text-2xl flex items-center">
<button class="mr-1" title="Add url to the list"
......
@font-face {
font-family: "Sacramento";
font-family: "Butterfly";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(data-base64:~assets/Sacramento.woff2) format("woff2");
src: url(data-base64:~assets/Butterfly.woff2) format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
U+FEFF, U+FFFD;
......
This diff is collapsed.
{
"type": "service_account",
"project_id": "leaf-0001",
"private_key_id": "aa9c1ca35ae771a1706a18d5a9f06b3acef37cdf",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDjmz/bKMfO3xpH\npY7+bXUQ0WGApKhN8IzsjxwzfjkVZPEk3NbVnvWDF06diySMpl60MQ/ZRLxrGeEg\nbcEKT7H8YZJTku/smhFr3UUoiTeOFnjL0XWgd8W30VN/dDZr6QXYG4jCeh3YeuY1\nO1gKUz71p+E2QsRUJTFvELVJKYjLMkM2YUZAOHuVLtgtgn9yWi/+3FgGlpXft9kx\n8XALbFY5h8Bp5/DiPvUcv8PDOJ8jeo6fY+G78F4epxAxt75sKYvw8or38cgZFKLX\nW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zQFnSacrhNLunOQb4CQV0uwZonGXrKUSLpEum8DHBt\nreAj3vqYu1XtVAPLTgD6bi6jzlYrACYI7ukJVKJjAoGAXgcGsh2B+S57sualhbGi\na0qB4qR87NkUJ/K3du0DqwNecbzWSoEIOQjefrOWaaoZMlnN0iQQZfX/EN892Yjf\n7CaSHUAJaBXnRwmvQAcJnDB6oP2CrNI//1cYRb4oNEmAdI9YASQPGUmC7Jpqwgd8\nTnHXn3jBAwOIK+bHV3f9wGc=\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-1e2vt@leaf-0001.iam.gserviceaccount.com",
"client_id": "109628992619565425852",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-1e2vt%40leaf-0001.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
import firebase_admin
from firebase_admin import credentials, firestore
import json
# Initialize Firebase Admin SDK
cred = credentials.Certificate("key.json") # Path to your Firebase service account key
firebase_admin.initialize_app(cred)
# Initialize Firestore client
db = firestore.client()
def load_data_from_json(json_file_path, collection_name):
try:
with open(json_file_path, 'r') as file:
data = json.load(file)
# Add each document to the collection
for doc_id, doc_data in enumerate(data):
# Create a dictionary to store the data for the document
doc_to_add = {
"brand": doc_data["brand"],
"country": doc_data["COUNTRY"],
"animal_welfare": doc_data["Animal_Welfare"],
"biodiversity_conservation": doc_data["Biodiversity_Conservation"],
"energy_greenhouse_gas_emissions": doc_data["Energy_Greenhouse_Gas_Emissions"],
"restricted_substance_list": doc_data["Restricted_Substance_List"],
"waste_recycling_packaging_retail": doc_data["Waste_Recycling_Packaging_Retail"],
"waste_recycling_product_textiles": doc_data["Waste_Recycling_Product_Textiles"],
"water_consumption": doc_data["Water_Consumption"],
"environmental_total": doc_data["environmental_total"],
"supplier_annual_leave_public_holidays": doc_data["Supplier_Annual_Leave_Public_Holidays"],
"supplier_anti_bribery_corruption": doc_data["Supplier_Anti_bribery_Corruption"],
"supplier_biodiversity_conservation": doc_data["Supplier_Biodiversity_Conservation"],
"supplier_child_labour": doc_data["Supplier_Child_Labour"],
"supplier_community_engagement": doc_data["Supplier_Community_Engagement"],
"supplier_discrimination": doc_data["Supplier_Discrimination"],
"supplier_energy_greenhouse_gas_emissions": doc_data["Supplier_Energy_Greenhouse_Gas_Emissions"],
"supplier_equal_pay": doc_data["Supplier_Equal_Pay"],
"supplier_forced_labour": doc_data["Supplier_Forced_Labour"],
"supplier_freedom_of_association": doc_data["Supplier_Freedom_of_Association"],
"supplier_harassment_violence": doc_data["Supplier_Harassment_Violence"],
"supplier_health_safety": doc_data["Supplier_Health_Safety"],
"supplier_homeworking": doc_data["Supplier_Homeworking"],
"supplier_living_conditions": doc_data["Supplier_Living_Conditions"],
"supplier_maternity_rights_parental_leave": doc_data["Supplier_Maternity_Rights_Parental_Leave"],
"supplier_overtime_pay": doc_data["Supplier_Overtime_Pay"],
"supplier_subcontracting": doc_data["Supplier_Subcontracting"],
"supplier_wages_benefits": doc_data["Supplier_Wages_Benefits"],
"supplier_waste_recycling_packaging_retail": doc_data["Supplier_Waste_Recycling_Packaging_Retail"],
"supplier_waste_recycling_product_textiles": doc_data["Supplier_Waste_Recycling_Product_Textiles"],
"supplier_water_consumption": doc_data["Supplier_Water_Consumption"],
"supplier_working_hours_breaks": doc_data["Supplier_Working_Hours_Breaks"],
"supplier_ethical_standards": doc_data["Supplier_Ethical_Standards"],
"supplychain_total": doc_data["supplychain_total"],
"annual_leave_public_holidays": doc_data["Annual_Leave_Public_Holidays"],
"anti_bribery_corruption": doc_data["Anti_bribery_Corruption"],
"community_engagement": doc_data["Community_Engagement"],
"discrimination": doc_data["Discrimination"],
"diversity_inclusion": doc_data["Diversity_Inclusion"],
"equal_pay": doc_data["Equal_Pay"],
"freedom_of_association": doc_data["Freedom_of_Association"],
"harassment_violence": doc_data["Harassment_Violence"],
"health_safety": doc_data["Health_Safety"],
"maternity_rights_parental_leave": doc_data["Maternity_Rights_Parental_Leave"],
"mental_health_wellbeing": doc_data["Mental_Health_Wellbeing"],
"wages_benefits": doc_data["Wages_Benefits"],
"working_hours_breaks": doc_data["Working_Hours_Breaks"],
"social_total": doc_data["social_total"]
# Add more fields as needed
}
# Add the document to the collection
db.collection(collection_name).add(doc_to_add)
print("Data successfully loaded into the collection '{}'".format(collection_name))
except Exception as e:
print("Error loading data:", str(e))
# Example usage
json_file_path = "dataset.json" # Path to your JSON file
collection_name = "companies" # Name of the collection in Firestore
load_data_from_json(json_file_path, collection_name)
\ No newline at end of file
......@@ -3,7 +3,7 @@
@tailwind utilities;
.logo {
font-family: "Sacramento";
font-family: "Butterfly";
}
.font-roboto {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment