Skip to main content

Transfer flatfile format

Overview

Purpose:

The underlying problem, which the project tackles is that Amazon provides different flatfile formats. Either because the user chooses different elements or because amazon applies changes to an existing format. In both cases, it is impossible to simply copy and paste data in between formats, when the column headers don't match.

Strategy:

Find a sub-set of rows, that match a certain condition (don't contain any values, besides the provided SKU), pull the missing data from an external source supplied through the command line option (-o/--original). Map a fallback value for the SKU from the google sheet by searching for one inside of a plentymarkets export (this is a very specific option usable for our system). Write the data to the google-sheet in form of smaller chunks (to avoid problems occuring with uploading >10000 values at once to the API).

Installation:

  • python3 -m pip install transfer_flatfile_format --user --upgrade

  • On Windows you additionally need the Visual studio build tools 2019, as that is required by numpy

  • Place the credentials file from: Google sheets tutorial into the data folder (see section: 'Usage'). (~/.transfer_flatfile_format/.credentials.json)

  • Enter the google-sheets document ID into the config.ini file. (see section 'Usage')

Usage:

There are four options:

  • --orginal / -o:
    • File location of the flatfile format, which is used as source for the values
  • --exclude / -e:
    • Comma-separated list of column names (3rd row of a flatfile), to exclude from writing to the google sheet (use case: some columns from the source contain outdated values)
  • --column / -c:
    • A column name (3rd row of a flatfile), to exclusivly transfer from the source to the google sheet
  • --adjust / -a (only in combination with --column):
    • Use the python expression defined within the config under section: [Adjust] option: 'command' to modify a value from the source flatfile before writing it to the google-sheet.
    • Example: command=(X)*2 will multiply the numbers from the column specified with --column before writing it to the gsheet.
    • These expressions are not "smart", so judge on your own if your data can be modified by a single expression.

Additionally, there is the config.ini file within:

  • ~/.transfer_flatfile_format/config.ini (on Linux)
  • C:\Users{USER}.transfer_flatfile_format (on Windows)

Which is used to specify the ID of the google sheet and optionally a data source for alternative SKUs. The alternative SKU can be used if your system maintains more than one SKU for one entity. That way you can match a product with one of two possible terms.

Example:

config.ini

[General]
google_sheet_id=1PB_XrUqy6qk......
[Match table]
with_matchtable={y|n}
sku_export={Link to csv file or location in file system}
main_sku={column_name of the column where the main SKU is located}
alt_sku={column_name of the column where the alternative SKU is located}
[Adjust]
command=(X)+5//4
Example 1: Upload all values from the source file to the google sheet, when the google sheet has an SKU but no values in 'brand_name' or 'item_name':

python3 -m transfer_flatfile_format -o /home/path/to/source_file.csv

Example 2: Upload all values from the source file at column 'example_column' to the google sheet:

python3 -m transfer_flatfile_format -o /home/path/to/source_file.csv -c example_column

Example 3: Do the same as with 'Example 1' but do not update the columns 'example_col1' & 'example_col2':

python3 -m transfer_flatfile_format -o /home/path/to/source_file.csv -e example_col1,example_col2

Example 4: Get values from a column containing integers and add 3 to them:

python3 -m transfer_flatfile_format -o /home/path/to/source_file.csv -c numeric_column -a

Config:

[General]
google_sheet_id=1PB_XrUqy6qk......
[Adjust]
command=(X)+3

Metadata

Release files for transfer-flatfile-format 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for transfer-flatfile-format 0.1.3
File Size Uploaded Provenance Actions
transfer_flatfile_format-0.1.3.tar.gz 22.7 kB Without provenance Details for transfer_flatfile_format-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for transfer-flatfile-format 0.1.3
File Interpreter ABI Platform Actions
transfer_flatfile_format-0.1.3-py3-none-any.whl Python 3 none any Details for transfer_flatfile_format-0.1.3-py3-none-any.whl

Total release size: 46.0 kB

Release files / transfer_flatfile_format-0.1.3.tar.gz

Download URL transfer_flatfile_format-0.1.3.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
55d65a53c9a6e7cd49df9f0245048779c4fc4f05c0d73ede88efce3400b697af
BLAKE2b-256 checksum
How to use checksums
fc057b24d7247249f5e5b908beeed9441428b7b7466ff903666f741f3dc06dc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.7.3 Linux/5.8.0-rc6

Release files / transfer_flatfile_format-0.1.3-py3-none-any.whl

Download URL transfer_flatfile_format-0.1.3-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6495a989ed13b549619d720c8f23212771f2951d8168a119862c898fbf7aea1
BLAKE2b-256 checksum
How to use checksums
c54eaeb7e2b56fa1dd4c197700059298ead3db4079789697c764f6624d583b99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.7.3 Linux/5.8.0-rc6

Security for transfer-flatfile-format 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page