imort CSV files
This commit is contained in:
@ -23,6 +23,7 @@ class CsvImporter:
|
||||
|
||||
self.csv_path = csv_path
|
||||
self.coin = coin
|
||||
# --- FIX: Corrected the f-string syntax for the table name ---
|
||||
self.table_name = f"{self.coin}_1m"
|
||||
self.db_path = os.path.join("_data", "market_data.db")
|
||||
self.column_mapping = {
|
||||
@ -86,6 +87,10 @@ class CsvImporter:
|
||||
# Clean and format the data
|
||||
df.rename(columns=self.column_mapping, inplace=True)
|
||||
df['datetime_utc'] = pd.to_datetime(df['datetime_utc'])
|
||||
|
||||
# --- FIX: Calculate the millisecond timestamp from the datetime column ---
|
||||
# This converts the datetime to nanoseconds and then to milliseconds.
|
||||
df['timestamp_ms'] = (df['datetime_utc'].astype('int64') // 10**6)
|
||||
|
||||
# Filter the data to find only rows that are outside the range of what's already in the DB
|
||||
if db_oldest and db_newest:
|
||||
@ -145,3 +150,5 @@ if __name__ == "__main__":
|
||||
|
||||
importer = CsvImporter(log_level=args.log_level, csv_path=args.file, coin=args.coin)
|
||||
importer.run()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user