Это не так уж сложно, если вы держите весь файл целиком в памяти, но для больших файлов это невозможно.
Код: Выделить всё
# using .read() holds the entire file open in memory - not ideal
df = pd.read_parquet(s3_response['Body'].read(), columns=columns)
Моя проблема в том, что это кажется, что это невозможно сделать с помощью Parquet, поскольку Parquet кодирует данные как в нижнем колонтитуле файла, так и в заголовке.
Вот пример моего кода:
Код: Выделить всё
session = boto3.session.Session()
s3_client = session.client(
service_name='s3',
endpoint_url=s3_url,
)
obj = s3_client.get_object(Bucket=s3_bucket, Key=key)
for line in obj['Body'].iter_lines():
pq_file = io.BytesIO(line)
df = pd.read_parquet(pq_file, columns=columns)
# At this point I'd want to iterate over the DF rows
# and send them to kafka
print(df)
Код: Выделить всё
OSError: Could not open parquet input source '': Invalid: Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.Подробнее здесь: https://stackoverflow.com/questions/663 ... g-in-memor