ilds 2.3.2__tar.gz → 2.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {ilds-2.3.2 → ilds-2.3.4}/PKG-INFO +1 -1
  2. {ilds-2.3.2 → ilds-2.3.4}/ilds/excel.py +51 -2
  3. {ilds-2.3.2 → ilds-2.3.4}/ilds/versions.py +1 -1
  4. {ilds-2.3.2 → ilds-2.3.4}/ilds.egg-info/PKG-INFO +1 -1
  5. {ilds-2.3.2 → ilds-2.3.4}/README.rst +0 -0
  6. {ilds-2.3.2 → ilds-2.3.4}/ilds/__init__.py +0 -0
  7. {ilds-2.3.2 → ilds-2.3.4}/ilds/cmd.py +0 -0
  8. {ilds-2.3.2 → ilds-2.3.4}/ilds/django/__init__.py +0 -0
  9. {ilds-2.3.2 → ilds-2.3.4}/ilds/django/admin.py +0 -0
  10. {ilds-2.3.2 → ilds-2.3.4}/ilds/django/import_export.py +0 -0
  11. {ilds-2.3.2 → ilds-2.3.4}/ilds/django/model.py +0 -0
  12. {ilds-2.3.2 → ilds-2.3.4}/ilds/django/user.py +0 -0
  13. {ilds-2.3.2 → ilds-2.3.4}/ilds/django/util.py +0 -0
  14. {ilds-2.3.2 → ilds-2.3.4}/ilds/everything.py +0 -0
  15. {ilds-2.3.2 → ilds-2.3.4}/ilds/excel_xlrd.py +0 -0
  16. {ilds-2.3.2 → ilds-2.3.4}/ilds/excel_xlsx.py +0 -0
  17. {ilds-2.3.2 → ilds-2.3.4}/ilds/file.py +0 -0
  18. {ilds-2.3.2 → ilds-2.3.4}/ilds/lib/__init__.py +0 -0
  19. {ilds-2.3.2 → ilds-2.3.4}/ilds/lib/browsercookie.py +0 -0
  20. {ilds-2.3.2 → ilds-2.3.4}/ilds/lib/configobj/__init__.py +0 -0
  21. {ilds-2.3.2 → ilds-2.3.4}/ilds/lib/configobj/_version.py +0 -0
  22. {ilds-2.3.2 → ilds-2.3.4}/ilds/lib/configobj/validate.py +0 -0
  23. {ilds-2.3.2 → ilds-2.3.4}/ilds/lib/hexdump.py +0 -0
  24. {ilds-2.3.2 → ilds-2.3.4}/ilds/match_data.py +0 -0
  25. {ilds-2.3.2 → ilds-2.3.4}/ilds/md.py +0 -0
  26. {ilds-2.3.2 → ilds-2.3.4}/ilds/md5summer.py +0 -0
  27. {ilds-2.3.2 → ilds-2.3.4}/ilds/mycsv.py +0 -0
  28. {ilds-2.3.2 → ilds-2.3.4}/ilds/net.py +0 -0
  29. {ilds-2.3.2 → ilds-2.3.4}/ilds/pd.py +0 -0
  30. {ilds-2.3.2 → ilds-2.3.4}/ilds/spider.py +0 -0
  31. {ilds-2.3.2 → ilds-2.3.4}/ilds/time.py +0 -0
  32. {ilds-2.3.2 → ilds-2.3.4}/ilds/util.py +0 -0
  33. {ilds-2.3.2 → ilds-2.3.4}/ilds.egg-info/SOURCES.txt +0 -0
  34. {ilds-2.3.2 → ilds-2.3.4}/ilds.egg-info/dependency_links.txt +0 -0
  35. {ilds-2.3.2 → ilds-2.3.4}/ilds.egg-info/requires.txt +0 -0
  36. {ilds-2.3.2 → ilds-2.3.4}/ilds.egg-info/top_level.txt +0 -0
  37. {ilds-2.3.2 → ilds-2.3.4}/setup.cfg +0 -0
  38. {ilds-2.3.2 → ilds-2.3.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: ilds
3
- Version: 2.3.2
3
+ Version: 2.3.4
4
4
  Summary: 常用模块的集合,为了多平台,多电脑调用方便!
5
5
  Home-page: https://github.com/ldsxp/ilds
6
6
  Author: lds
@@ -140,7 +140,7 @@ class ReadExcel:
140
140
  print(excel.set_sheet(10)) # 这个要判断下是否成功
141
141
  print(excel.next_sheet(), excel.sheet_index)
142
142
  """
143
- # print('args', args,'kwargs',kwargs)
143
+ # print('args', args, 'kwargs', kwargs)
144
144
  # 打开的表索引,可以指定默认值
145
145
  self.sheet_index = kwargs.pop('sheet_index', 0)
146
146
 
@@ -159,7 +159,17 @@ class ReadExcel:
159
159
 
160
160
  # self.excel = 'xlsx'
161
161
  # 加载工作簿
162
- self.wb = load_workbook(*args, **kwargs)
162
+ if args or 'filename' in kwargs:
163
+ try:
164
+ self.wb = load_workbook(*args, **kwargs)
165
+ except FileNotFoundError:
166
+ # 如果文件不存在,创建一个新的工作簿
167
+ self.wb = Workbook()
168
+ print(f'{args} {kwargs} 文件不存在,创建新表格')
169
+ else:
170
+ self.wb = Workbook()
171
+ print('创建新表格')
172
+
163
173
  self.sheet_names = self.wb.sheetnames
164
174
  self.set_sheet(self.sheet_index)
165
175
  # print(self.excel)
@@ -324,6 +334,45 @@ def save_dir_excel_specified_rows(file_dir, dst_dir=None, num_rows=10):
324
334
  save_excel_specified_rows(input_file=file, output_file=dst_dir / f'{os.path.basename(file)} {num_rows}行.xlsx', start_row=1, end_row=num_rows + 1)
325
335
 
326
336
 
337
+ def split_excel(excel_file, save_dir=None, save_sheets=None, exclude=None):
338
+ """
339
+ 拆分 Excel
340
+ """
341
+ if save_sheets is None:
342
+ # 加载Excel文件
343
+ original_wb = load_workbook(filename=excel_file)
344
+
345
+ # 获取所有的工作表名字
346
+ save_sheets = original_wb.sheetnames
347
+
348
+ # 循环保存表
349
+ for sheet_to_keep in save_sheets:
350
+
351
+ if exclude and sheet_to_keep in exclude:
352
+ print(f'忽略保存工作表: {sheet_to_keep}')
353
+
354
+ # 重新加载工作簿
355
+ wb = load_workbook(filename=excel_file)
356
+
357
+ # 获取所有的工作表名称
358
+ sheets = wb.sheetnames
359
+
360
+ # 删除除当前工作表外的其他工作表
361
+ for sheet_name in sheets:
362
+ if sheet_name != sheet_to_keep:
363
+ std = wb[sheet_name]
364
+ wb.remove(std)
365
+
366
+ if save_dir:
367
+ save_file = os.path.join(save_dir, f"{sheet_to_keep}.xlsx")
368
+ else:
369
+ save_file = f"{sheet_to_keep}.xlsx"
370
+
371
+ # 保存为新文件
372
+ wb.save(save_file)
373
+ print(f"工作表 '{sheet_to_keep}' 保存为 '{save_file}'")
374
+
375
+
327
376
  def write_to_excel(file_name, sheet_name, data, start_cell='A1'):
328
377
  try:
329
378
  # 尝试加载存在的工作簿
@@ -1,4 +1,4 @@
1
- version = '2.3.2'
1
+ version = '2.3.4'
2
2
 
3
3
  # 因为日期格式问题,所以下面的版本号不能使用
4
4
  # 主版本号 (Major Version): 较大的功能变化或结构调整
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: ilds
3
- Version: 2.3.2
3
+ Version: 2.3.4
4
4
  Summary: 常用模块的集合,为了多平台,多电脑调用方便!
5
5
  Home-page: https://github.com/ldsxp/ilds
6
6
  Author: lds
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes