티스토리 뷰

 

Repo 주소 : https://github.com/dedupeio/csvdedupe

 

GitHub - dedupeio/csvdedupe: Command line tool for deduplicating CSV files

:id: Command line tool for deduplicating CSV files - GitHub - dedupeio/csvdedupe: Command line tool for deduplicating CSV files

github.com

 

 

설치

pip install csvdedupe

 

사용법

> csvdedupe 입력파일명.csv --field_names "컬럼명" --output_file 출력파일명.csv

field_names에는 deduplication 확인을 할 컬럼명을 써준다.

 

 

이 때 유의할 사항!

한번이라도 실행한 후 같은 경로에서 다시 실행하면 아래와 같은 에러가 발생한다.

'ValueError: Records do not line up with data model. The field '컬럼명' is in data_model but not in a record'

컬럼명도 정확하고 NaN 값이 있는 것도 아닌데 원인이 뭐지 했는데, https://github.com/dedupeio/csvdedupe/issues/77 이 이슈를 통해 해결할 수 있었다.

해결방법은 그냥 다른 경로에서 실행해주면 된다!

 

 

실행이 정상적으로 되었다면, 위와 같이 뜬다.

입력 파일에 존재하는 데이터 두 쌍을 뽑아서 보여주고, 두 쌍이 duplicate한지(y) 혹은 distinct한지(n)를 사용자가 판단해서 입력하도록 한다. positive와 negative 값이 각각 최소 10개가 될 때까지 입력을 해준다.

이는 레이블링 과정인데, 이 최소 20쌍의 레이블링된 데이터를 기반으로 로지스틱 회귀를 통해 weight를 학습해 나머지 데이터에 대해 deduplication을 수행한다고 한다.

각각 10개가 넘어도 자동으로 끝나지 않으므로 f를 입력해서 입력을 종료한다. 

 

실행이 모두 완료되고 출력파일을 열어보면 Deduplication이 수행된 파일을 얻을 수 있다~

 

반응형

댓글