Skip to content

Commit ad81086

Browse files
fix test
fix test
1 parent 19f3444 commit ad81086

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.github/workflows/validate_csv.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ name: Validate CSV Files
33
on:
44
push:
55
branches:
6-
- main
6+
- master
77
pull_request:
8+
types:
9+
- opened # Trigger when a PR is opened
10+
- synchronize # Trigger when new commits are pushed to the PR
11+
- reopened # Trigger if the PR is reopened
812
branches:
9-
- main
13+
- master
1014

1115
jobs:
1216
validate:

validate_csv.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import re
33
import pandas as pd
4+
from sys import exit
45

56
# Define the ISO 8601 timestamp regex
67
iso_regex = r"^\s*$|^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}$"
@@ -12,7 +13,7 @@ def is_iso8601(timestamp):
1213
def validate_csv(file_path):
1314
"""Check if the CSV file has correct format"""
1415
try:
15-
df = pd.read_csv(file_path)
16+
df = pd.read_csv(file_path, skipinitialspace=True, comment="#")
1617
except Exception as e:
1718
return False, f"Error reading CSV file: {e}"
1819

@@ -22,9 +23,10 @@ def validate_csv(file_path):
2223

2324
# Validate t0 and t1 columns for correct format
2425
for index, row in df.iterrows():
25-
if not is_iso8601(str(row['t0'])) or not is_iso8601(str(row['t1'])):
26-
return False, f"Invalid t0/t1 timestamp format in file {file_path} at row {index + 1}"
27-
26+
if str(row['t0']).strip() not in ['', 'nan'] and not is_iso8601(str(row['t0'])):
27+
return False, f"Invalid t0 timestamp format in file {file_path} at row {index + 1}"
28+
if str(row['t1']).strip() not in ['', 'nan'] and not is_iso8601(str(row['t1'])):
29+
return False, f"Invalid t1 timestamp format in file {file_path} at row {index + 1}"
2830
return True, "Valid CSV file."
2931

3032
def validate_folder(folder_path):

0 commit comments

Comments
 (0)