DataComparerLibrary 0.846__tar.gz → 0.847__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 (23) hide show
  1. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/PKG-INFO +1 -1
  2. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/field.py +8 -0
  3. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/fileconverter.py +36 -4
  4. datacomparerlibrary-0.847/src/DataComparerLibrary/version.py +3 -0
  5. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary.egg-info/PKG-INFO +1 -1
  6. datacomparerlibrary-0.846/src/DataComparerLibrary/version.py +0 -3
  7. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/LICENSE.txt +0 -0
  8. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/README.rst +0 -0
  9. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/pyproject.toml +0 -0
  10. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/setup.cfg +0 -0
  11. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/setup.py +0 -0
  12. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/__init__.py +0 -0
  13. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/datacomparer.py +0 -0
  14. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/datasorter.py +0 -0
  15. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/datetimehandler.py +0 -0
  16. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/delimitertranslator.py +0 -0
  17. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/report.py +0 -0
  18. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/row.py +0 -0
  19. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/tools.py +0 -0
  20. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary/twodarray.py +0 -0
  21. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary.egg-info/SOURCES.txt +0 -0
  22. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary.egg-info/dependency_links.txt +0 -0
  23. {datacomparerlibrary-0.846 → datacomparerlibrary-0.847}/src/DataComparerLibrary.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DataComparerLibrary
3
- Version: 0.846
3
+ Version: 0.847
4
4
  Summary: For comparing csv-files, 2d-array with a csv-file or 2d-arrays. For comparing text-files, text variable with a text-file or text variables. Including a sorting module.
5
5
  Home-page:
6
6
  Author: René Philip Zuijderduijn
@@ -20,6 +20,9 @@ class Field:
20
20
  expected_data_with_wildcard = None
21
21
  skip_exception_rule_used = False
22
22
 
23
+ if self.field_data == other_field_including_templates_and_literals.field_data:
24
+ return True
25
+
23
26
  # Replace literal templates with fixed external strings.
24
27
  other_field_data_including_templates = self.__replace_template_literals_dict(other_field_including_templates_and_literals.field_data, template_literals_dict)
25
28
 
@@ -30,6 +33,11 @@ class Field:
30
33
  if Field.__is_same_value_but_different_types(self, other_field_data_including_templates):
31
34
  return False
32
35
 
36
+ if isinstance(other_field_data_including_templates, int):
37
+ # A real integer.
38
+ Report.show_differences_comparation_result(self.row_nr, self.column_nr, self.field_data, other_field_data_including_templates, "There is a difference between actual and expected data. No match with literals or templates.")
39
+ return False
40
+
33
41
  # If data in actual and expected field doesn't match, check if a template has been used in expected data.
34
42
  match other_field_data_including_templates.upper():
35
43
  case "{PRESENT}":
@@ -2,12 +2,16 @@
2
2
  # The files are open in binary mode.
3
3
  # Currently, methods are implemented to remove or replace a separate linefeed within a record. Records are ended by carriage return linefeed.
4
4
  #
5
+ import csv
6
+ import openpyxl
5
7
  import os
6
8
  import re
9
+ import warnings
7
10
 
8
11
 
9
12
  class FileConverter:
10
- def remove_separate_lf(self, input_file, output_file):
13
+ @staticmethod
14
+ def remove_separate_lf(input_file, output_file):
11
15
  # Remove separate linefeed (LF), so carriage return linefeed (CRLF) remains.
12
16
  try:
13
17
  if not os.path.exists(input_file):
@@ -24,7 +28,8 @@ class FileConverter:
24
28
  raise Exception("Error message: ", type(error).__name__, "–", error)
25
29
 
26
30
 
27
- def replace_separate_lf(self, input_file, output_file, replacement_string, encoding_replacement_string='utf-8'):
31
+ @staticmethod
32
+ def replace_separate_lf(input_file, output_file, replacement_string, encoding_replacement_string='utf-8'):
28
33
  # Replace separate linefeed (LF), so carriage return linefeed (CRLF) remains.
29
34
  try:
30
35
  if not os.path.exists(input_file):
@@ -43,7 +48,8 @@ class FileConverter:
43
48
  raise Exception("Error message: ", type(error).__name__, "–", error)
44
49
 
45
50
 
46
- def remove_cr_and_lf(self, input):
51
+ @staticmethod
52
+ def remove_cr_and_lf(input):
47
53
  # Remove carriage return (CR) and linefeed (LF) from input string.
48
54
  print("input: ", input)
49
55
  output = str(input).replace("\r", "").replace("\n", "")
@@ -52,10 +58,36 @@ class FileConverter:
52
58
  return output
53
59
 
54
60
 
55
- def replace_cr_and_lf(self, input, replacement_string):
61
+ @staticmethod
62
+ def replace_cr_and_lf(input, replacement_string):
56
63
  # Replace carriage return (CR) and linefeed (LF) from input string.
57
64
  print("input: ", input)
58
65
  output = str(input).replace("\r", replacement_string).replace("\n", replacement_string)
59
66
  print("output: ", output)
60
67
  #
61
68
  return output
69
+
70
+
71
+ @staticmethod
72
+ def convert_excel_file_to_csv_file(excel_file, csv_file):
73
+ if not os.path.exists(excel_file):
74
+ raise Exception("Input file doesn't exists: ", excel_file)
75
+
76
+ if not excel_file.endswith('.xslx') and not excel_file.endswith('.xslm') and not excel_file.endswith('.xls') and not excel_file.endswith('.xlm'):
77
+ raise Exception("Input file is not a Excel-file: ", excel_file)
78
+
79
+ if not excel_file.endswith('.csv'):
80
+ raise Exception("Input file is not a csv-file: ", csv_file)
81
+
82
+ with warnings.catch_warnings():
83
+ warnings.filterwarnings("ignore", message="Workbook contains no defaultstyle", category=UserWarning)
84
+ #
85
+ excel = openpyxl.load_workbook(excel_file)
86
+ # select the active sheet
87
+ sheet = excel.active
88
+ #
89
+ # write the data in a csv-file
90
+ col = csv.writer(open(csv_file, 'w', newline=""))
91
+ #
92
+ for row in sheet.rows:
93
+ col.writerow([cell.value for cell in row])
@@ -0,0 +1,3 @@
1
+ # encoding=utf-8
2
+
3
+ VERSION = '0.847'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DataComparerLibrary
3
- Version: 0.846
3
+ Version: 0.847
4
4
  Summary: For comparing csv-files, 2d-array with a csv-file or 2d-arrays. For comparing text-files, text variable with a text-file or text variables. Including a sorting module.
5
5
  Home-page:
6
6
  Author: René Philip Zuijderduijn
@@ -1,3 +0,0 @@
1
- # encoding=utf-8
2
-
3
- VERSION = '0.846'