Skip to content

Instantly share code, notes, and snippets.

@shirayu
Created August 2, 2022 10:49
Show Gist options
  • Save shirayu/f5ee81980e18f77e00f22e62bf681817 to your computer and use it in GitHub Desktop.
Save shirayu/f5ee81980e18f77e00f22e62bf681817 to your computer and use it in GitHub Desktop.
import csv
import fileinput
import sys
w = csv.writer(sys.stdout)
for cols in csv.reader(fileinput.input()):
w.writerow(
[cols[i] for i in [0, 1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 11, 10]]
+ ["*", "*", "*", "*", "*"]
)
@shirayu
Copy link
Author

shirayu commented Aug 2, 2022

.split(",") だと以下のような行のパースに失敗する (unidic-cwj-3.1.0/lex_3_1.csvより)

"(,_,)",10592,12455,-2205,補助記号,AA,顔文字,*,*,*,*,(,_,),(,_,),*,(,_,),*,記号,*,*,*,*,*,*,補助,*,*,*,*,*,*,*,77752248259715584,282861

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment