Skip to content

Commit 47b3701

Browse files
authored
Update rjj.py
1 parent 8cec033 commit 47b3701

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

rjj.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# !/usr/bin/env python3
22

3-
__version__="0.9.4"
3+
__version__="0.9.5"
44

55
import argparse, io, os, json, csv, glob, hashlib, warnings, base64, random, math
66
from sklearn.base import BaseEstimator, TransformerMixin
@@ -22,6 +22,21 @@ def list_json_files():
2222
def list_html_files():
2323
return [f for f in os.listdir() if f.endswith('.html')]
2424

25+
def csv_to_txt():
26+
csv_files = list_csv_files()
27+
for csv_file in csv_files:
28+
txt_file = os.path.splitext(csv_file)[0] + '.txt'
29+
try:
30+
with open(csv_file, 'r', newline='', encoding='utf-8') as infile, \
31+
open(txt_file, 'w', newline='', encoding='utf-8') as outfile:
32+
reader = csv.reader(infile)
33+
for row in reader:
34+
outfile.write('\t'.join(row) + '\n')
35+
print(f"Converted: {csv_file} -> {txt_file}")
36+
except Exception as e:
37+
print(f"Error converting {csv_file}: {e}")
38+
print("Conversion completed.")
39+
2540
def generate_png(file_path, png_width, png_height):
2641
from PIL import Image
2742
image = Image.new("RGBA", (png_width, png_height), (0, 0, 0, 0))
@@ -3547,6 +3562,7 @@ def __init__():
35473562
subparsers.add_parser('minify', help='minify js')
35483563
subparsers.add_parser('mj', help='minify json')
35493564
subparsers.add_parser('mh', help='minify html')
3565+
subparsers.add_parser('txt', help='convert all csv to txt')
35503566
subparsers.add_parser('png', help='create transparent png')
35513567
subparsers.add_parser('gif', help='create gif animation')
35523568
subparsers.add_parser('cut', help='cut timestamp')
@@ -3598,6 +3614,8 @@ def __init__():
35983614
base64codeHandler()
35993615
elif args.subcommand == 'json':
36003616
json_merger()
3617+
elif args.subcommand == 'txt':
3618+
csv_to_txt()
36013619
elif args.subcommand == 'gif':
36023620
create_gif()
36033621
elif args.subcommand == 'png':

0 commit comments

Comments
 (0)