Browse Source

display measurements and tolerances

bscheibel 5 years ago
parent
commit
6701b0f8cf
1 changed files with 42 additions and 10 deletions
  1. 42 10
      read_data.py

+ 42 - 10
read_data.py

@@ -7,28 +7,60 @@ with open('merged.csv') as csv_file:
     durchmesser = False
     vorzeichen = "nix"
     text = True
+    isos = []
+    dimensions = []
     for row in csv_reader:
-        #row[1] = row[1].replace(",",".")
+        line_count += 1
+
+        if "ISO" in row[1]:
+            isos.append(row[1])
         if durchmesser:
-            print("Durchmesser: " + row[1])
-        durchmesser = False
-        #continue
+            #print("Durchmesser: " + row[1])
+            dimensions.append("Durchmesser: " + row[1])
+            durchmesser = False
+            continue
         if row[1] == "%%c":
             durchmesser = True
         if row[1] == "-" or row[1] == "+":
             vorzeichen = row[1]
-            #print(vorzeichen)
         isnumber = re.findall(r"\d*\,\d+", row[1])
         if isnumber:
             if vorzeichen != "nix":
-                print(vorzeichen + isnumber[0])
+                #print(vorzeichen + isnumber[0])
+                dimensions.append(vorzeichen + isnumber[0])
             else:
-                print(isnumber[0])
+                if row[1][0]!="?":
+                    #print(isnumber[0])
+                    dimensions.append(isnumber[0])
             vorzeichen = "nix"
-
         if row[1][0] == "?":
-            print("+/- " + row[1][1:])
+            #print("+/- " + row[1][1:])
+            dimensions.append("+/- " + row[1][1:])
 
-        line_count += 1
+    print(isos)
+    #print(dimensions)
     print(f'Processed {line_count} lines.')
 
+    dim = []
+    dim_count = 0
+    for x in dimensions:
+        if x == "Durchmesser: ":
+            dim_count = 0
+        if dim_count > 2:
+            dim_count = 0
+        if dim_count == 0:
+            print("Maße: " + "\n" + x)
+            dim_count += 1
+            continue
+        if dim_count == 1:
+            print ("Toleranzen: " + "\n" + x)
+            dim_count += 1
+            if "+/-" in x:
+                dim_count += 1
+            continue
+        if dim_count == 2:
+            print(x)
+            dim_count += 1
+            continue
+
+