1
1
# !/usr/bin/env python3
2
2
3
- __version__ = "0.9.4 "
3
+ __version__ = "0.9.5 "
4
4
5
5
import argparse , io , os , json , csv , glob , hashlib , warnings , base64 , random , math
6
6
from sklearn .base import BaseEstimator , TransformerMixin
@@ -22,6 +22,21 @@ def list_json_files():
22
22
def list_html_files ():
23
23
return [f for f in os .listdir () if f .endswith ('.html' )]
24
24
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
+
25
40
def generate_png (file_path , png_width , png_height ):
26
41
from PIL import Image
27
42
image = Image .new ("RGBA" , (png_width , png_height ), (0 , 0 , 0 , 0 ))
@@ -3547,6 +3562,7 @@ def __init__():
3547
3562
subparsers .add_parser ('minify' , help = 'minify js' )
3548
3563
subparsers .add_parser ('mj' , help = 'minify json' )
3549
3564
subparsers .add_parser ('mh' , help = 'minify html' )
3565
+ subparsers .add_parser ('txt' , help = 'convert all csv to txt' )
3550
3566
subparsers .add_parser ('png' , help = 'create transparent png' )
3551
3567
subparsers .add_parser ('gif' , help = 'create gif animation' )
3552
3568
subparsers .add_parser ('cut' , help = 'cut timestamp' )
@@ -3598,6 +3614,8 @@ def __init__():
3598
3614
base64codeHandler ()
3599
3615
elif args .subcommand == 'json' :
3600
3616
json_merger ()
3617
+ elif args .subcommand == 'txt' :
3618
+ csv_to_txt ()
3601
3619
elif args .subcommand == 'gif' :
3602
3620
create_gif ()
3603
3621
elif args .subcommand == 'png' :
0 commit comments