I will be a copy-paste craftsman ╭ (・ ㅂ ・) و ̑̑ Good!
╰ (`• ω •) ╮-= ni <It is troublesome to make various things from the free QR code creation site. I can't create a website that sets parameters and generates a QR code (꒪ ཫ ꒪;)
item | version | Remarks |
---|---|---|
Python | 3.7.5 |
item | version | Remarks |
---|---|---|
pandas | --- | Used to read an Excel file |
xlrd | --- | Needed to load excel in pandas |
PyInstaller | --- | exe conversion |
qrcode | --- | QR code generation |
Pillow | --- | png image creation |
Used to align the environment
requirements.txt
altgraph==0.17
colorama==0.4.3
future==0.18.2
numpy==1.19.0
pandas==1.0.5
pefile==2019.4.18
Pillow==7.1.2
pip==19.2.3
PyInstaller==3.6
python-dateutil==2.8.1
pytz==2020.1
pywin32-ctypes==0.2.0
qrcode==6.1
setuptools==41.2.0
six==1.15.0
xlrd==1.2.0
--Click OK as it is (you can install the package when creating a virtual environment)
ExcelToQRCode.py
import sys
import os
import pandas as pd
import qrcode
import base64
def main():
#Command line arguments
args = sys.argv
#Do not process if the argument is less than two
if len(args) < 2:
exit()
#Excel file judgment
split = os.path.splitext(args[1])
if split[1] != '.xlsx':
exit()
#Get the first sheet
excel_data = pd.read_excel(args[1], sheet_name = 0, encoding='utf-8')
param_list = []
for i, row in excel_data.iterrows():
if i > 0:
temp = ""
for value in row.iloc[2:8]:
temp += str(value) + '|'
temp = temp[:-1]
full_path = os.getcwd() +'\\' + row.iloc[1] + '.png'
param_list.append((full_path, temp))
for index in range(len(param_list)):
image_qr = qrcode.make(base64.b64encode(param_list[index][1].encode('utf-8')))
image_qr.save(param_list[index][0])
if len(param_list) < 1:
print("There was no QR code to create")
else:
print("I created a QR code")
if __name__ == '__main__':
main()
Type the following command to make it an exe The file size of the exe becomes big, but I close my eyes (˘ω˘)
python
pyinstaller hoge.py --onefile --noconsole
--onefile --Combine in one file
--noconsole ――No black screen
Drag & drop xlsx file to exe
Utility.cs
public static class Utility
{
public static string Base64Decode(string value)
{
return System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(value));
}
public static List<string> GetQRCordData(string value)
{
string data = Utility.Base64Decode(value);
return new List<string>(data.Split(new[] { "|" }, System.StringSplitOptions.None));
}
}
Recommended Posts