Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
44 changes: 44 additions & 0 deletions .store/.0_import/Import tools/CSV2DB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import subprocess
import tkinter as tk
from tkinter import filedialog, messagebox

# Create the GUI window
window = tk.Tk()

# Function to handle button click and execute the conversion
def convert_csv_to_db():
# Prompt for input file
csv_file = filedialog.askopenfilename(title="Select CSV File", filetypes=[("CSV Files", "*.csv")])

# Prompt for output directory
output_directory = filedialog.askdirectory(title="Select Output Directory")

# Prompt for output file name (without extension)
output_name = tk.simpledialog.askstring("Output File Name", "Enter the desired name for the output database file (without extension): ")

if csv_file and output_directory and output_name:
# Append a unique number to the output file name
output_file = output_name + "_01.db"
index = 1
while output_file in os.listdir(output_directory):
index += 1
output_file = f"{output_name}_{index:02d}.db"

try:
# Execute the csvs-to-sqlite command using subprocess
subprocess.run(["csvs-to-sqlite", csv_file, os.path.join(output_directory, output_file)], check=True)
messagebox.showinfo("Conversion Successful", "CSV file converted to SQLite database successfully!")
except subprocess.CalledProcessError as e:
messagebox.showerror("Conversion Error", f"An error occurred during the conversion:\n{e}")
else:
messagebox.showwarning("Input Missing", "Please provide all required input.")

# Create the button
button = tk.Button(window, text="Convert CSV to SQLite DB", command=convert_csv_to_db)

# Configure the button position
button.pack()

# Start the GUI event loop
window.mainloop()
24 changes: 24 additions & 0 deletions .store/.0_import/Import tools/atomFeedStructurePuller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import requests
from bs4 import BeautifulSoup

url = "https://example.com/atom_feed.xml"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'xml')

feed_elements = {}

for element in soup.find_all():
tag_name = element.name
if tag_name not in feed_elements:
feed_elements[tag_name] = []

attributes = {}
for attr, value in element.attrs.items():
attributes[attr] = value

feed_elements[tag_name].append(attributes)

for tag_name, attributes_list in feed_elements.items():
print(f"{tag_name}:")
for attributes in attributes_list:
print(f" - {attributes}")
24 changes: 24 additions & 0 deletions .store/.0_import/Import tools/atomFeedStructurePullerV2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import requests
from bs4 import BeautifulSoup

url = "https://www.upwork.com/ab/feed/jobs/atom?q=Photoshop&sort=recency&job_type=hourly%2Cfixed&proposals=0-4%2C5-9%2C10-14%2C15-19&budget=50-&verified_payment_only=1&hourly_rate=25-&paging=0%3B50&api_params=1&securityToken=5d53fdd5809c340cfe7034341784f715c8433ec350191c7f0ee5607d91b69227dc8481c3ef14b654d0a87a7211a52622e824e33ae3cce04de57c7398856752ec&userUid=1327243219150897152&orgUid=1327243219155091457"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'xml')

feed_elements = {}

for element in soup.find_all():
tag_name = element.name
if tag_name not in feed_elements:
feed_elements[tag_name] = []

attributes = {}
for attr, value in element.attrs.items():
attributes[attr] = value

feed_elements[tag_name].append(attributes)

for tag_name, attributes_list in feed_elements.items():
print(f"{tag_name}:")
for attributes in attributes_list:
print(f" - {attributes}")
2,546 changes: 2,546 additions & 0 deletions .store/.0_import/Import tools/clean_atom_feed_entries.csv

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions .store/.0_import/Prototype/Default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import os
import sqlite3
import pandas as pd
import sys

# Check if the correct number of arguments have been provided
if len(sys.argv) != 2:
print(r"Usage: 'C:\Users\Martin\OneDrive - studiocordillera.com 1\Documents\.GITHUB_Repos\datasette\venv\Scripts\python.exe' Default.py <csv_file>")
sys.exit(1)

# Assign arguments to variables
csv_file = sys.argv[1]
output_directory = r"C:\Users\Martin\OneDrive - studiocordillera.com 1\Documents\.GITHUB_Repos\datasette\.store\.0_import\Prototype" # Replace with your default directory
output_name = "default_output" # Replace with your default output name

# Preview the first 5 lines of the CSV file
df = pd.read_csv(csv_file)
print(df.head())

# Append a unique number to the output file name
index = 1
output_file = output_name + "_01.db"
while output_file in os.listdir(output_directory):
index += 1
output_file = f"{output_name}_{index:02d}.db"

# Create connection to SQLite database
conn = sqlite3.connect(os.path.join(output_directory, output_file))

# Use pandas to_sql() function to write records stored in DataFrame to SQLite database
df.to_sql('table_name', conn, if_exists='replace', index=False)

# Close connection
conn.close()

# Reopen the SQLite connection
conn = sqlite3.connect(os.path.join(output_directory, output_file))
# Query the database and print out the result
df_check = pd.read_sql_query("SELECT * from table_name", conn)
print(df_check)

# Close the SQLite connection again
conn.close()

print("CSV file converted to SQLite database successfully!")

# Wait for user input before exiting
input("Press any key to continue...")

16 changes: 16 additions & 0 deletions .store/.0_import/Prototype/Drop.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off
setlocal

:: Get the full path of the dropped file
set "csv_file=%~f1"

:: Activate the virtual environment
call "C:\Users\Martin\OneDrive - studiocordillera.com 1\Documents\.GITHUB_Repos\datasette\venv\Scripts\activate.bat"

:: Call the Python script with the full path of the dropped file as an argument
python "C:\Users\Martin\OneDrive - studiocordillera.com 1\Documents\.GITHUB_Repos\datasette\.store\.0_import\Prototype\Default.py" "%csv_file%"

:: Add a pause to see the output in the cmd window
pause

endlocal
Loading