File tree Expand file tree Collapse file tree
getcloser/backend/app/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77rows = []
88id_counter = 1
99
10- with open (input_file , newline = "" , encoding = "utf-8" ) as f :
10+ with open (input_file , newline = "" , encoding = "utf-8-sig " ) as f :
1111 reader = csv .DictReader (f )
1212
1313 for row in reader :
1414 user_id = row ["idx" ]
15+ if user_id == "idx" :
16+ # Skip duplicated header row in data.
17+ continue
1518
1619 # category 1: 관심사 키워드 (JSON 리스트)
17- interests = json .loads (row ["interest_keywords" ])
20+ raw_interest_keywords = (row .get ("interest_keywords" ) or "" ).strip ()
21+ if raw_interest_keywords :
22+ try :
23+ interests = json .loads (raw_interest_keywords )
24+ except json .JSONDecodeError :
25+ # Fallback for non-JSON input like "a,b,c"
26+ interests = [value .strip () for value in raw_interest_keywords .split ("," ) if value .strip ()]
27+ else :
28+ interests = []
1829 for interest in interests :
1930 rows .append ([
2031 id_counter ,
You can’t perform that action at this time.
0 commit comments