Permalink
Browse files

Added Sample Python Script

Decent sample script to copy and build upon
  • Loading branch information...
1 parent 28d8e4f commit 6544fd53ab354aa142bcdf697e70c0b446eb2796 @BrianPainter BrianPainter committed Jan 18, 2012
@@ -0,0 +1,23 @@
+11339C-014,1,WEIGHT,16372
+11339C-014,1,LENGTH,28.5
+11339C-014,1,WIDTH,2.0
+11339C-014,1, 10, , ,*,100
+11339C-014,1, 20, , ,*,100
+11339C-014,1, 30, , ,*,100
+11339C-014,1, 40,CNN741,4.04,*,100
+11339C-014,1, 50,INX063,4,*,100
+11339C-014,1, 60,INX070,1,*,100
+11339C-014,1, 70,RSX11333,4,*,100
+11339C-014,1, 80,RSX08047,4,*,100
+11339C-014,1, 90,PAX028,4,*,100
+11339C-014,1, 100,11339SBX04002,27,*,100
+11339C-014,1, 110,11339SBX04001,16,*,100
+11339C-014,1, 120,11339SBX06002,2,*,100
+11339C-014,1, 130,11339SBX06001,2,*,100
+11339C-014,1, 140,PVX212017,6,*,100
+11339C-014,1, 150,11339SBX06006,8,*,100
+11339C-014,1, 160,PSX500,114,*,100
+11339C-014,1, 170,PAX018,4,*,100
+11339C-014,1, 180,11339SPX004,2,*,100
+11339C-014,1, 190,11339SPX001,2,*,100
+11339C-014,1, 200,RBX04203,6,*,100
@@ -0,0 +1,20 @@
+11339C-016,1,WEIGHT,15681
+11339C-016,1,LENGTH,28.5
+11339C-016,1,WIDTH,2.0
+11339C-016,1, 10, , ,*,100
+11339C-016,1, 20, , ,*,100
+11339C-016,1, 30, , ,*,100
+11339C-016,1, 40,CNN741,4.1,*,100
+11339C-016,1, 50,INX063,4,*,100
+11339C-016,1, 60,INX070,1,*,100
+11339C-016,1, 70,RSX11333,4,*,100
+11339C-016,1, 80,RSX08047,4,*,100
+11339C-016,1, 90,PAX028,4,*,100
+11339C-016,1, 100,11339SBX04002,27,*,100
+11339C-016,1, 110,11339SBX04001,16,*,100
+11339C-016,1, 120,11339SBX06002,2,*,100
+11339C-016,1, 130,11339SBX06001,2,*,100
+11339C-016,1, 140,PVX212017,3,*,100
+11339C-016,1, 150,11339SBX06006,8,*,100
+11339C-016,1, 160,PSX500,114,*,100
+11339C-016,1, 170,PAX018,2,*,100
@@ -0,0 +1,8 @@
+shopcards_cleaner is a simple script to modify text files
+to be in the proper format for uploading to another system
+
+Main Features:
+* opens a directory and finds all of the text files within that directory
+* splits each line and checks to see if the fourth element is empty, and if so, removes the line
+* removes the last line feed character from the last line in the file
+* writes the changed file back to the original file name
@@ -0,0 +1,32 @@
+import os
+
+path = "//tcsdc2/PROJECTS/Issued"
+extension = ".txt"
+
+# Get all of the files that we need to check
+list_of_files = [file for file in os.listdir(path) if file.lower().endswith(extension)]
+for file2 in list_of_files:
+ # Open the file
+ shopcard = open(path + "/" + file2, "r+")
+ # Read in all of the lines
+ lines = shopcard.readlines()
+ # Remove any lines that don't have a part number on them
+ to_remove = []
+ for line in lines:
+ items = line.split(",")
+ if cmp(items[3], "") == 0:
+ to_remove.append(line)
+
+ for line2 in to_remove:
+ lines.remove(line2)
+
+ # remove the last \n if one exists
+ lines.reverse()
+ lines[0] = lines[0].rstrip('\r\n')
+ lines.reverse()
+
+ # Write the modified lines back to the text file
+ shopcard.seek(0)
+ shopcard.truncate()
+ shopcard.writelines(lines)
+ shopcard.close

0 comments on commit 6544fd5

Please sign in to comment.