taskforce-dev commited on
Commit
dc6b00a
·
1 Parent(s): 6a92c8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -13,8 +13,8 @@ def process_csv(input_file):
13
  df.insert(0, '行形式', '')
14
 
15
  # Drop specified columns
16
- columns_to_drop = ['伝票連番', '連番行番号', '行番号', '伝票区分', '商品コード', '商品名区分',
17
- '売上数量_在庫用数量', '売上金額', '形番号', 'ユーザーNO1', '得意先名', '郵便番号',
18
  '住所1', '住所2', '電話番号', '受注_図面番号', '受注_サイズ']
19
  df.drop(columns_to_drop, axis=1, inplace=True, errors='ignore')
20
 
@@ -25,7 +25,8 @@ def process_csv(input_file):
25
  '商品名': '品名',
26
  '売上数量_請求用数量': '数量',
27
  '売上単価': '単価',
28
- '行摘要': '件名',
 
29
  '受注_備考': 'メモ'
30
  }
31
  df.rename(columns=column_name_mapping, inplace=True)
@@ -47,7 +48,7 @@ def process_csv(input_file):
47
  new_group.iloc[0, new_group.columns.get_loc('数量')] = ''
48
  new_group.iloc[0, new_group.columns.get_loc('単価')] = ''
49
  new_group.iloc[0, new_group.columns.get_loc('単位')] = ''
50
- clear_cols = ['得意先コード', '請求日', '請求番号', '名', 'メモ']
51
  for col in clear_cols:
52
  if col in new_group.columns:
53
  new_group.iloc[1:, new_group.columns.get_loc(col)] = ''
@@ -61,6 +62,12 @@ def process_csv(input_file):
61
 
62
  return output_file_path
63
 
 
 
 
 
 
 
64
  # Webアプリを作成
65
  app = gr.Interface(fn=process_csv, inputs="file", outputs="file")
66
  # Webアプリを起動
 
13
  df.insert(0, '行形式', '')
14
 
15
  # Drop specified columns
16
+ columns_to_drop = ['伝票連番', '連番行番号', '得意先コード', '行番号', '伝票区分', '商品コード', '商品名区分',
17
+ '売上数量_在庫用数量', '売上金額', '形番号', 'ユーザーNO1', '郵便番号',
18
  '住所1', '住所2', '電話番号', '受注_図面番号', '受注_サイズ']
19
  df.drop(columns_to_drop, axis=1, inplace=True, errors='ignore')
20
 
 
25
  '商品名': '品名',
26
  '売上数量_請求用数量': '数量',
27
  '売上単価': '単価',
28
+ '得意先名': 'タグ',
29
+ '行摘要': '得意先名',
30
  '受注_備考': 'メモ'
31
  }
32
  df.rename(columns=column_name_mapping, inplace=True)
 
48
  new_group.iloc[0, new_group.columns.get_loc('数量')] = ''
49
  new_group.iloc[0, new_group.columns.get_loc('単価')] = ''
50
  new_group.iloc[0, new_group.columns.get_loc('単位')] = ''
51
+ clear_cols = ['得意先コード', '請求日', '請求番号', 'タグ', '得意先名', 'メモ']
52
  for col in clear_cols:
53
  if col in new_group.columns:
54
  new_group.iloc[1:, new_group.columns.get_loc(col)] = ''
 
62
 
63
  return output_file_path
64
 
65
+ # Save the modified dataframe to the output file
66
+ output_file_path = "processed.csv"
67
+ df_modified.to_csv(output_file_path, index=False)
68
+
69
+ return output_file_path
70
+
71
  # Webアプリを作成
72
  app = gr.Interface(fn=process_csv, inputs="file", outputs="file")
73
  # Webアプリを起動