Skip to main content

No project description provided

Project description

xlsxgen

  • pip install で xlsxgenのモジュールを落として、pythonコードを以下の通り記述する。
    • スピード重視の場合はメソッド(process_bytes)をコメント解除する
    • メモリ容量を抑えたい場合はメソッド(process_bytes_zlib)と、zlipの圧縮処理の箇所をコメント解除する

使い方

import pandas as pd
import zipfile
import xlsxgen
import resource
import time
import io
import zlib

# 開始
start_time = time.perf_counter()
file_name = 'tenpo_shohin_pattern3.xlsx'
excel_sheet = 'sheet1'

with open(file_name, 'rb') as file_obj:
    with zipfile.ZipFile(file_obj, 'r') as zip_ref:
        # エクセルファイルを展開してオブジェクトを取得
        s_list = [f'xl/worksheets/{excel_sheet}.xml']
        sheet_list = [i for i in zip_ref.namelist() if i in s_list]
        solve_bytes = 'xl/sharedStrings.xml'
        bytes_obj = zip_ref.read([i for i in zip_ref.namelist() if i in sheet_list][0])
        bytes_solve_obj = zip_ref.read(solve_bytes)

        generator = xlsxgen.DataGenerator()

        # スピード重視のケース(メモリ容量は大きく消費する)
        generator.process_bytes(10000, bytes_obj, bytes_solve_obj)

        # メモリ容量を抑えたいケース(スピードは少し遅い)
        # bytes_obj = zlib.compress(bytes_obj)
        # bytes_solve_obj = zlib.compress(bytes_solve_obj)
        # generator.process_bytes_zlib(10000, bytes_obj, bytes_solve_obj)
        while True:
            csv_data = generator.generate_data_chunk()
            if csv_data == "finish":
                print(csv_data)
                break
            if csv_data:
                print(csv_data)
                #df = pd.read_csv(io.StringIO(csv_data), header=None)
                #print(df)

memory_info = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
print(f"Max RSS: {memory_info / 1024 / 1024} MB")

end_time = time.perf_counter()
# 経過時間を出力(秒)
elapsed_time = end_time - start_time
print(elapsed_time)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

xlsxgen-0.1.4-cp39-cp39-macosx_10_7_x86_64.whl (385.0 kB view details)

Uploaded CPython 3.9macOS 10.7+ x86-64

xlsxgen-0.1.4-cp38-none-win_amd64.whl (244.1 kB view details)

Uploaded CPython 3.8Windows x86-64

xlsxgen-0.1.4-cp38-cp38-macosx_10_7_x86_64.whl (384.6 kB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

File details

Details for the file xlsxgen-0.1.4-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for xlsxgen-0.1.4-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0c86ddfcf8026e8399dfa581dfde6a817c4062e1f2e876d1a2923590ae44f591
MD5 0a20167bf6fa279ec948f027d0fb2793
BLAKE2b-256 c9f96d46f93d935c7979824a25448d9b42a526e5f3c730ea7cf8f3653c85f260

See more details on using hashes here.

File details

Details for the file xlsxgen-0.1.4-cp38-none-win_amd64.whl.

File metadata

  • Download URL: xlsxgen-0.1.4-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 244.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.10

File hashes

Hashes for xlsxgen-0.1.4-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 1b5d85d1fcea773ebf16dd5df649a65e98fb16d8896a5b5568902510616a1f34
MD5 24bc3685f50327577a66a0ffd72455e7
BLAKE2b-256 4c92edc45b2abaf7cba357ce91dafa2d984ac78ae0b4af12ac664c86f0612f08

See more details on using hashes here.

File details

Details for the file xlsxgen-0.1.4-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for xlsxgen-0.1.4-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b88d623b25169a91af3565328216b41e1f6fbb4d09903b9ef99200631e273170
MD5 8994fe297e48edc8857a99048061458a
BLAKE2b-256 aae537207cde7c771b123b90d793eb0929f941338dd44da4a7bfefce08e289ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page