반응형

응용: 쉘 스크립트를 이용해 해당 디렉토리의 파일들 모두 변경 


- char-convert.sh

#!/bin/bash

 

LIST=`ls -A1 | grep ".csv"`

 

for file in $LIST

do

  python ./char-convert.py $file

done


- char-convert.py

#!/usr/bin/python

#-*- coding: utf-8 -*-

  

import codecs

import sys

 

file = sys.argv[1]

file2 = file.split('.csv')[0]+"-2.csv"

 

infile = codecs.open(file, 'r', encoding='utf-8')

outfile = codecs.open(file2, 'w', encoding='euc_kr')

  

for line in infile:

  line = line.replace(u'\xa0', ' ')  

  outfile.write(line)

    

infile.close()

outfile.close()


...

반응형

+ Recent posts