bartoszpet Posted July 30, 2023 Share Posted July 30, 2023 Convert CSV to XLSX Download URL: https://github.com/bpetrynski/alfred-convert-csv-to-xslx/ This is an Alfred Workflow that lets you convert CSV files to XSLX (Excel) format. This tool is very useful for data analysts or anyone who frequently works with data files and needs to convert them to a more user-friendly format for editing and visualization purposes. The conversion process is done by a Python script which reads a CSV file, converts it into a DataFrame (a two-dimensional tabular data structure with labeled axes), and then writes that DataFrame into an XLSX (Excel) file. Installation Step 1: Install Python (if not already installed): Open Terminal and type: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install python Step 2: Install the required Python libraries: We'll need two libraries: pandas for data manipulation and openpyxl for Excel file handling. To install these libraries, type the following command in Terminal: pip install pandas openpyxl Usage Use via Universal Actions in Alfred. Alfred's Universal Actions allow you to select a file in Finder or on your Desktop and apply an action to it, like converting the file format. In Environment Variables you can change the default encoding, delimiter, and quote character. Changelog 0.3 Added conversion parameters as variables: This enhancement allows you to set specific parameters for the conversion process as variables, giving you more control over the output. 0.2 Added autofiltering: This feature automatically applies filters to the columns in the Excel file, making it easier for you to sort and filter the data. Added freezing of the top row: Freezing the top row allows you to scroll down in the Excel file without losing sight of the column headers. 0.1 Initial version: Basic CSV to XSLX conversion functionality. Link to comment
vitor Posted July 31, 2023 Share Posted July 31, 2023 Welcome @bartoszpet, Looking good. A few tips for the workflow, which will make it more resilient and avoid a few issues:You don’t need to export PATH to add the Homebrew paths, Alfred includes those.Always prefer with input as argv over with input as {query}. As it is, your script will fail with certain file names.It’s common practice to bundle the libraries with the workflow. To include a Python package with the workflow, use the --target option and set PYTHONPATH. StackOverflow has other options. Always make sure to install with /usr/bin/python3 so packages are built with the system python.This is more of a question, but how’s the Keyword supposed to work? It doesn’t take an argument but the script seems to require a path. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now