필자는 pyarrow 라이브러리를 사용하여 폴더의 많은 쪽모이 세공 파일에 쓸 계획 인 수백만 개의 레코드 SQL 테이블을 보유하고 있습니다. 데이터 내용이 너무 커서 단일 쪽모 세공 파일에 저장할 수 없습니다. fastparquet 파이썬 라이브러리가 지원되기 때문에pyarrow는 fastparquet의 file_scheme = 'hive'옵션과 같은 폴더에 여러 가지 쪽매 파일을 쓸 수 있습니까?
file_scheme="hive"
:
그러나, 나는 내가 뭔가를 지정할 수 있습니다 pyarrow 라이브러리의 API 또는 매개 변수를 찾을 수 없습니다. 이 오류가 발생
#!/usr/bin/python
import pyodbc
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
conn_str = 'UID=username;PWD=passwordHere;' +
'DRIVER=FreeTDS;SERVERNAME=myConfig;DATABASE=myDB'
#----> Query the SQL database into a Pandas dataframe
conn = pyodbc.connect(conn_str, autocommit=False)
sql = "SELECT * FROM ClientAccount (NOLOCK)"
df = pd.io.sql.read_sql(sql, conn)
#----> Convert the dataframe to a pyarrow table and write it out
table = pa.Table.from_pandas(df)
pq.write_table(table, './clients/')
:
여기 내 예제 코드의
File "/usr/local/lib/python2.7/dist-packages/pyarrow/parquet.py", line 912, in write_table
os.remove(where)
OSError: [Errno 21] Is a directory: './clients/'
나는 다음과 마지막 줄은 잘 작동하지만 하나의 큰 파일을 쓰는 교체하는 경우 :
를pq.write_table(table, './clients.parquet')
저는 pyarrow로 다중 파일 출력을 할 수있는 아이디어가 있습니까?
필로와 함께 쓰여지는 데이터를 분할하는 방법을 찾았습니까? – Drew