Last active
May 12, 2020 20:40
-
-
Save jackbow/2294b787d5bdd0f927f9a62b7c4a9b1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"upload costco pdf to https://ocr.space/, with table recognition option & OCR Engine1. Save text output to file, set path to file path (2 cells down)\n", | |
"\n", | |
"import resultant csv to spreadsheet, and then clean up the file by creating searchable pdf, and searching by item number for missing prices" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import string\n", | |
"import re" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"path = 'temp.txt'\n", | |
"f = open(path,'r')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"lines = f.readlines()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"275" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"len(lines)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def hasNumbers(inputString):\n", | |
" return any(char.isdigit() for char in inputString)\n", | |
"\n", | |
"def hasAlpha(inputString):\n", | |
" return any(char.isalpha() for char in inputString)\n", | |
"\n", | |
"def split_on_char(s):\n", | |
" match = re.compile(\"[^\\W\\d]\").search(s)\n", | |
" return [s[:match.start()], s[match.start():]]\n", | |
"\n", | |
"def split_on_digit(s):\n", | |
" match = re.compile(\"\\d\").search(s)\n", | |
" return [s[:match.start()], s[match.start():]]\n", | |
"\n", | |
"def split_on_money(s):\n", | |
" match = re.compile(\"(\\d+)?\\.?\\d+$\").search(s)\n", | |
" return [s[:match.start()], s[match.start():]]\n", | |
"\n", | |
"def split_on_newline(s):\n", | |
" match = re.compile(\"\\\\n\").search(s)\n", | |
" return [s[:match.start()], s[match.start():]]\n", | |
"\n", | |
"def splitInsert(listt, idx, opt):\n", | |
" if opt == 'c':\n", | |
" csplit = split_on_char\n", | |
" if opt == 'd':\n", | |
" csplit = split_on_digit\n", | |
" if opt == 'm':\n", | |
" csplit = split_on_money\n", | |
" if opt == 'n':\n", | |
" csplit = split_on_newline\n", | |
" spp = csplit(listt[idx])\n", | |
" listt[idx] = spp[0]\n", | |
" listt.insert(idx+1, spp[1])\n", | |
" return listt" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"nlines = []\n", | |
"for i,v in enumerate(lines):\n", | |
" if not ((not v[0].isdigit()) or \n", | |
" (v[0] == '*') or\n", | |
" (v[0:9].count('/', 0, 8) >= 2) or\n", | |
" (v.count('icc.coop') > 0)):\n", | |
" \n", | |
" # split line\n", | |
" sp = v.split('\\t')\n", | |
" \n", | |
" # remove trailing spaces\n", | |
" for j in range(len(sp)):\n", | |
" if sp[j][-1] == ' ':\n", | |
" sp[j] = sp[j][0:-1]\n", | |
" \n", | |
" contains_nums = [True, False, False, True, True, False]\n", | |
" contains_alph = [False, True, True, True, False, False]\n", | |
" \n", | |
" # split bad data\n", | |
" if len(sp) != 6:\n", | |
" for j in range(len(sp)):\n", | |
" if (hasNumbers(sp[j]) != contains_nums[j] or\n", | |
" hasAlpha(sp[j]) != contains_alph[j]):\n", | |
" if j == 0:\n", | |
" sp = splitInsert(sp, j, 'c')\n", | |
" if j == 1:\n", | |
" sp = splitInsert(sp, j, 'd')\n", | |
" if j == 2:\n", | |
" if not sp[j][0].isdigit():\n", | |
" sp = splitInsert(sp, j, 'd')\n", | |
" elif sp[j][-1].isdigit():\n", | |
" sp = splitInsert(sp, j, 'm')\n", | |
" if j == 3:\n", | |
" if hasAlpha(sp[j]) and hasNumbers(sp[j]):\n", | |
" sp = splitInsert(sp, j, 'm')\n", | |
" elif sp[j][-1] == '\\n':\n", | |
" sp = splitInsert(sp, j, 'n')\n", | |
" if len(sp[j]) > 0 and (sp[j][-1] == '\\n'):\n", | |
" sp = splitInsert(sp, j, 'n')\n", | |
" \n", | |
" # fill missing data\n", | |
" if len(sp) != 6:\n", | |
" for j in range(len(sp)):\n", | |
" if (hasNumbers(sp[j]) != contains_nums[j] or\n", | |
" hasAlpha(sp[j]) != contains_alph[j]):\n", | |
" sp.insert(j, ' ')\n", | |
" if len(sp) == 6:\n", | |
" break\n", | |
" \n", | |
" # remove spaces in item # & price\n", | |
" sp[0] = sp[0].replace(' ', '')\n", | |
" sp[-2] = sp[-2].replace(' ', '')\n", | |
" \n", | |
" nlines.append('\\t'.join(sp))" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"if index error, run this code, and remove the \\t from the relevant part:\n", | |
"\n", | |
"`print(v)`\n", | |
"\n", | |
"`lines[i] = <the text with the extra \\t removed>`\n", | |
"\n", | |
"eg.\n", | |
"\n", | |
"`print(v): '843142\\tLOG CABIN\\tSYRUP\\t2/64 OUNCE CONTAINERS\\t6\\t.99\\t\\n'`\n", | |
"\n", | |
"`lines[i] = '843142\\tLOG CABIN\\tSYRUP\\t2/64 OUNCE CONTAINERS\\t6.99\\t\\n'`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"185" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"len(nlines)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"['18328\\tKIRKLAND SIGNATURE\\tFANCY CASHEWS\\t40 OUNCE JAR\\t14.99\\t\\n',\n", | |
" '27491\\tNABISCO\\tOREO COOKIES\\t52.5 OUNCE BOX\\t7.59\\t\\n',\n", | |
" '36285\\tKIRKLAND SIGNATURE\\tWALNUTS\\t48 OUNCE BAG\\t9.99\\t\\n',\n", | |
" '142354\\tNABISCO\\tRITZ CRACKERS\\t61.6 OUNCE BOX\\t7.99\\t\\n',\n", | |
" '23444\\tKIRKLAND SIGNATURE\\tPECAN HALVES\\t32 OUNCE BAG\\t12.99\\t\\n',\n", | |
" '204529\\tNABISCO\\tHONEY MAID GRAHAMS\\t57.6 OUNCE BOX\\t6.99\\t\\n',\n", | |
" '284601\\tKIRKLAND SIGNATURE\\tWHOLE ALMONDS\\t48 OUNCE BAG\\t11.99\\t\\n',\n", | |
" '833684\\tKIRKLAND SIGNATURE\\tORGANIC TORTILLA CHIPS\\t40 OUNCE BAG\\t4.79\\t\\n',\n", | |
" '938492\\tKIRKLAND SIGNATURE\\tKETTLE POTATO CHIPS\\t32 OUNCE BAG\\t4.59\\t\\n',\n", | |
" '946753\\tCRUNCHMASTER\\tMULTI-GRAIN 6 SEED\\t28 OUNCE BOX\\t9.69\\t\\n',\n", | |
" \"414\\tHELLMANN'S\\tMAYONNAISE\\t64 OUNCE CONTAINER\\t6.89\\t\\n\",\n", | |
" \"1228\\tCAMPBELL'S\\tCREAM OF MUSHROOM SOUP\\t12/10.5 OUNCE CANS\\t9.99\\t\\n\",\n", | |
" '2005\\tARDENT MILLS\\tALL PURPOSE FLOUR\\t25 POUND BAG\\t6.49\\t\\n',\n", | |
" '5354\\tHIDDEN VALLEY\\tHOMESTYLE RANCH\\t2/40 OUNCE BOTTLES\\t9.89\\t\\n',\n", | |
" '9440\\tTHAI KITCHEN\\tORGANIC COCONUT MILK\\t6/13.66 OUNCE CANS\\t8.99\\t\\n',\n", | |
" '9822\\tMADE IN NATURE\\tORGANIC APRICOTS\\t48 OUNCE BAG\\t9.99\\t\\n',\n", | |
" '17767\\tKIRKLAND SIGNATURE\\t100% COLOMBIAN COFFEE\\t3 POUND CAN\\t8.59\\t\\n',\n", | |
" '20389\\tSARA LEE\\tHONEY WHEAT BREAD\\t2/20 OUNCE LOAVES\\t3.39\\t\\n',\n", | |
" '27398\\tGREY POUPON\\tDIJON MUSTARD\\t2/16 OUNCE JARS\\t6.79\\t\\n',\n", | |
" '46176\\tKIRKLAND SIGNATURE\\tBALSAMIC VINEGAR\\t33.8 OUNCE BOTTLE\\t10.99\\t\\n',\n", | |
" '49000\\tKIRKLAND SIGNATURE\\tORGANIC VANILLA SOY\\t12/32 OUNCE\\t10.49\\t\\n',\n", | |
" '71003\\tKIRKLAND SIGNATURE\\t100% ITALIAN EXTRA\\tVIRGIN OLIVE OIL 2L\\t15.99\\t\\n',\n", | |
" '118677\\tNESTLE TOLL HOUSE\\tSEMI-SWEET MORSELS\\t72 OUNCE BAG\\t8.79\\t\\n',\n", | |
" \"144482\\tKELLOGG'S\\tFROSTED MINI WHEATS\\t2/35 OUNCE BAGS\\t8.29\\t\\n\",\n", | |
" '158996\\tKIRKLAND SIGNATURE\\tFRESH PRESSED APPLE\\t2/128 OUNCE\\t8.89\\t\\n',\n", | |
" '159491\\tKIRKLAND SIGNATURE\\tORGANIC MARINARA SAUCE \\t3/32 OUNCE\\t9.49\\t\\n',\n", | |
" '164950\\tKIRKLAND SIGNATURE\\tWHOLE BLACK PEPPERCORN \\t14.1 OUNCE CONTAINER\\t4.99\\t\\n',\n", | |
" '164981\\tKIRKLAND SIGNATURE\\tFINE GROUND PEPPER\\t12.3 OZ CONTAINER\\t4.69\\t\\n',\n", | |
" '190235\\tPOST BRANDS\\tHONEY BUNCHES OF OATS\\t2/24 OUNCE BAGS\\t5.89\\t\\n',\n", | |
" '289685\\tSUN MAID\\tORGANIC RAISINS\\t2/32 OUNCE BAGS\\t10.69\\t\\n',\n", | |
" '316689\\tLOTUS FOODS\\tORG MILLET & BROWN\\tRICE RAMEN 1.875 POUND\\t7.99\\t\\n',\n", | |
" '367636\\tGEDNEY\\tBABY DILL PICKLES\\t64 OUNCE JAR\\t\\t\\n',\n", | |
" \"383456\\tSWEET BABY RAY'S\\tBARBEQUE SAUCE\\t2/40 OUNCE BOTTLES\\t5.49\\t\\n\",\n", | |
" '421793\\tKIRKLAND SIGNATURE\\tORGANIC STRAWBERRY\\tSPREAD 42 OUNCE JAR\\t6.99\\t\\n',\n", | |
" '443298\\tKRAFT\\tEASY MAC CUPS\\t12/2.05 OUNCE CUPS\\t6.49\\t\\n',\n", | |
" '446586\\tQUAKER\\tOLD FASHIONED OATMEAL\\t2/80 OUNCE BAGS\\t8.29\\t\\n',\n", | |
" '512690\\tKIRKLAND SIGNATURE\\tGOLDEN SWEET CORN\\t12/15.25 OUNCE CANS\\t5.99\\t\\n',\n", | |
" '516822\\tKIRKLAND SIGNATURE\\tORGANIC CHICKEN STOCK\\t6/32 OUNCE BOXES\\t\\t\\n',\n", | |
" '518090\\tKIRKLAND SIGNATURE\\tARTICHOKE HEARTS\\t2/33 OUNCE JARS\\t\\t\\n',\n", | |
" '522107\\tGENERAL MILLS\\tCHEERIOS\\t2/20.35 OUNCE BOXES\\t5.79\\t\\n',\n", | |
" '533372\\tKIRKLAND SIGNATURE\\tPURE HONEY\\t5 POUND CONTAINER\\t11.99\\t\\n',\n", | |
" '539142\\tKIRKLAND SIGNATURE\\tORGANIC SALSA\\t2/38 OUNCE JARS\\t7.49\\t\\n',\n", | |
" '549721\\tHEINZ\\tSIMPLY HEINZ KETCHUP\\t3/44 OUNCE BOTTLES\\t\\t\\n',\n", | |
" '555000\\tKIRKLAND SIGNATURE\\tORGANIC PEANUT BUTTER\\t2/28 OUNCE JARS\\t9.99\\t\\n',\n", | |
" '571542\\tITALIAN VOLCANO\\tORGANIC LEMON JUICE\\t2/1 LITER BOTTLES\\t8.49\\t\\n',\n", | |
" '584531\\tGENERAL MILLS\\tLUCKY CHARMS\\t2/23 OUNCE BOXES\\t\\t\\n',\n", | |
" '586335\\tKIRKLAND SIGNATURE\\tORGANIC RICE BEVERAGE\\t12/32 OUNCE BOXES\\t12.59\\t\\n',\n", | |
" '596444\\tKIRKLAND SIGNATURE\\t100% JUICE CRANBERRY\\t2/96 OUNCE BOTTLES\\t6.99\\t\\n',\n", | |
" '633561\\tKIRKLAND SIGNATURE\\tORGANIC DICED TOMATOES \\t8/14.5 OUNCE CANS\\t5.99\\t\\n',\n", | |
" '633563\\tKIRKLAND SIGNATURE\\tORGANIC TOMATO SAUCE\\t12/15 OUNCE CANS\\t7.79\\t\\n',\n", | |
" '633564\\tKIRKLAND SIGNATURE\\tORGANIC TOMATO PASTE\\t12/6 OUNCE CANS\\t5.99\\t\\n',\n", | |
" '664511\\tORGANIC BLACK BEANS\\t8/15 OUNCE CANS\\t6.99\\t\\t\\n',\n", | |
" '664927\\tGENERAL MILLS\\tCINNAMON TOAST CRUNCH\\t2/24.75 OUNCE BAGS\\t6_99\\t\\n',\n", | |
" \"676704\\tFRENCH'S\\tYELLOW MUSTARD\\t2/30 OUNCE BOTTLES\\t4.89\\t\\n\",\n", | |
" '694682\\tORGANIC GARBANZO BEANS \\t \\t8/15OUNCECANS\\t\\n',\n", | |
" '734786\\tGENERAL MILLS\\tHONEY NUT CHEERIOS\\t2/27.5 OUNCE BOXES\\t7.29\\t\\n',\n", | |
" '736083\\tKIRKLAND SIGNATURE\\tORGANIC LEMONADE\\t2/96 OUNCE\\t5.99\\t\\n',\n", | |
" '761486\\tGAROFALO\\tORGANIC SPAGHETFI\\t8/17.6 OUNCE PACKS\\t9.99\\t\\n',\n", | |
" '790652\\tSO DELICIOUS\\tORGANIC COCONUT MILK\\t6/32 OUNCE BOXES\\t9.99\\t\\n',\n", | |
" '807473\\tKIRKLAND SIGNATURE\\tSEMI-SWEET CHOC CHIPS\\tCACAO 4.5LBS\\t9.99\\t\\n',\n", | |
" \"821666\\tAUNT MILLIE'S\\tHAMBURGER BUNS\\t16 COUNT PACKAGE\\t\\t\\n\",\n", | |
" '843142\\tLOG CABIN\\tSYRUP\\t2/64 OUNCE CONTAINERS\\t6.99\\t\\n',\n", | |
" '859695\\tKIRKLAND SIGNATURE\\tALMOND BUTTER\\t27 OUNCE JAR\\t7.79\\t\\n',\n", | |
" '864984\\tGAROFALO\\tORG TRI COLOR VARIETY\\t6/1.1 POUND PACK\\t9.69\\t\\n',\n", | |
" '906410\\tKIRKLAND SIGNATURE\\tCANOLA OIL\\t2/3 QUART BOTTLES\\t7.29\\t\\n',\n", | |
" '912291\\tKIRKLAND SIGNATURE\\tALBACORE TUNA\\t8/7 OUNCE CANS\\t\\t\\n',\n", | |
" '917538\\tJIF\\tCRUNCHY PEANUT BUTTER\\t2/48 OUNCE JARS\\t\\t\\n',\n", | |
" '917546\\tJIF\\tCREAMY PEANUT BUTTER\\t2/48 OUNCE JARS\\t8.99\\t\\n',\n", | |
" '928726\\tMCCORMICK\\tORGANIC BASIL\\t2.85 OUNCE CONTAINER\\t\\t\\n',\n", | |
" '935109\\tLEA & PERRINS\\tWORCESTERSHIRE SAUCE\\t2/20 OUNCE BOTTLES\\t6.99\\t\\n',\n", | |
" \"945452\\tKELLOGG'S\\tSPECIAL K RED BERRIES\\t2/21.5 OUNCE BAGS\\t8.89\\t\\n\",\n", | |
" '950750\\tLINDSAY\\tLG PITTED BLACK OLIVES\\t8/6 OUNCE\\t9.99\\t\\n',\n", | |
" '962005\\tHEALTHY CHOICE\\tCHICKEN SOUP VARIETY\\t10/15 OUNCE CANS\\t9.89\\t\\n',\n", | |
" '978635\\tSPICE ISLANDS\\tGROUND CUMIN SEED\\t15 OUNCE CONTAINER\\t4.99\\t\\n',\n", | |
" '979855\\tKIRKLAND SIGNATURE\\tJAPANESE GREEN TEA\\t100 COUNT BOX\\t12.99\\t\\n',\n", | |
" '1001368\\tKIRKLAND SIGNATURE\\tORGANIC QUINOA\\t4.5 POUND BAG\\t9.99\\t\\n',\n", | |
" '1002373\\tKIRKLAND SIGNATURE\\tORG ALMOND BEVERAGE\\t6/32 OUNCE BOXES\\t\\t\\n',\n", | |
" '1009581\\tGUERRERO\\tFLOUR TORTILLAS\\t2/15 COUNT PACKAGES\\t3.99\\t\\n',\n", | |
" '1028862\\tGREAT LAKES\\tRAW MICHIGAN HONEY\\t40 OUNCE CONTAINER\\t8.99\\t\\n',\n", | |
" '1045706\\tKIRKLAND SIGNATURE\\tORGANIC COCONUT OIL\\t84 OUNCE JAR\\t13.99\\t\\n',\n", | |
" '1062943\\tORGANIC NABISCO\\tTRISCUIT\\t36 OUNCE BOX\\t9.59\\t\\n',\n", | |
" '1072687\\tPURE VANILLA EXTRACT\\t16 OUNCE BOTTLE\\t29.99\\t\\t\\n',\n", | |
" '1074184\\tKIRKLAND SIGNATURE\\tOLIVE OIL\\t2/3 LITER BOTTLES\\t22.99\\t\\n',\n", | |
" '1120945\\tKIRKLAND SIGNATURE\\tHIMALAYAN PINK SALT\\t80 OUNCE CONTAINER\\t6.69\\t\\n',\n", | |
" \"1122506\\tFRANK'S\\tRED HOT SAUCE\\t2/25 OUNCE BOTTLES\\t6.69\\t\\n\",\n", | |
" \"1127681\\tRAO'S\\tHOMEMADE MARINARA\\t40 OUNCE JAR\\t7.99\\t\\n\",\n", | |
" '1143330\\tOCEAN SPRAY\\tCRAISINS\\t64 OUNCE BAG\\t8.99\\t\\n',\n", | |
" '1147377\\tKIRKLAND SIGNATURE\\tORGANIC BLUE AGAVE\\t2/36 oz\\t8.99\\t\\n',\n", | |
" '1219113\\tKIRKLAND SIGNATURE\\tORGANIC APPLE CIDER\\tVINEGAR 3/32 OUNCE\\t6.99\\t\\n',\n", | |
" '1230230\\tMAZOLA\\t100% CORN OIL\\t2.75 GALLON CONTAINER\\t17.99\\t\\n',\n", | |
" '1296566\\tWHITE EMERALD\\tLONG GRAIN RICE\\t25 POUNDS\\t8.49\\t\\n',\n", | |
" '1298243\\tSUNNY FRUIT\\tORGANIC DRIED FIGS\\t40 OUNCE BAG\\t\\t\\n',\n", | |
" '1312346\\tMADE IN NATURE\\tORGANIC DATES\\t40 OUNCE BAG\\t8.49\\t\\n',\n", | |
" '720\\tREYNOLDS\\tSTANDARD FOIL\\t2/250 SQ FT ROLLS\\t16.99\\t\\n',\n", | |
" '295861\\tKIRKLAND SIGNATURE\\tENV FRIENDLY DISH SOAP\\t135 OUNCE BOTTLE\\t\\t\\n',\n", | |
" '512599\\tKIRKLAND SIGNATURE\\tCREATE-A-SIZE TOWELS\\t12/160 SHEET ROLLS\\t16.49\\t\\n',\n", | |
" '585578\\tKIRKLAND SIGNATURE\\t2 PLY BATH TISSUE\\t30/425 SHEET ROLLS\\t16.99\\t\\n',\n", | |
" '773084\\tKIRKLAND SIGNATURE\\tPARCHMENT PAPER\\t2/205 SQ FT ROLLS\\t9.99\\t\\n',\n", | |
" '845621\\tKIRKLAND SIGNATURE\\tULTRA FREE&CLEAR HE\\t126 LOADS/194 OUNCES\\t13.99\\t\\n',\n", | |
" '1089787\\tKIRKLAND SIGNATURE\\tFLEX-TECH KITCHEN BAGS\\t13 GAL - 200 COUNT PKG\\t14.69\\t\\n',\n", | |
" '1121474\\tSCOTCH-BRITE\\tNON-SCRATCH SPONGE\\t21 COUNT PACKAGE\\t12.99\\t\\n',\n", | |
" '1158369\\tZIPLOC\\tSANDWICH BAGS\\t4/145 COUNT BOXES\\t11.59\\t\\n',\n", | |
" '3\\tKIRKLAND SIGNATURE\\tWHOLE MILK\\tONE GALLON\\t2.59\\t\\n',\n", | |
" '8\\tKIRKLAND SIGNATURE\\t2% REDUCED FAT MILK\\tONE GALLON\\t2.25\\t\\n',\n", | |
" '763\\tRASKAS\\tCREAM CHEESE\\t6/8 OUNCE PACKAGES\\t6.99\\t\\n',\n", | |
" '22093\\tKIRKLAND SIGNATURE\\tSHARP CHEDDAR CHEESE\\t2 POUND BLOCK\\t4.99\\t\\n',\n", | |
" '22102\\tKIRKLAND SIGNATURE\\tCOLBY JACK CHEESE\\t2 POUND BLOCK\\t5.49\\t\\n',\n", | |
" '22107\\tKIRKLAND SIGNATURE\\tSHREDDED CHEDDAR JACK\\t2/2.5 POUND BAGS\\t12.99\\t\\n',\n", | |
" '70000\\tKIRKLAND SIGNATURE\\tPREMIUM SLICED BACON\\t4/1 POUND PACKAGES\\t13.99\\t\\n',\n", | |
" '106913\\tKIRKLAND SIGNATURE\\tFAT FREE MILK\\tONE GALLON\\t1.99\\t\\n',\n", | |
" '210110\\tDAISY COTTAGE CHEESE\\tPURE & NATURAL\\t3 POUND TUB\\t4.59\\t\\n',\n", | |
" '319047\\tMOUNTAIN HIGH\\tPLAIN LOWFAT YOGHURT\\t4 POUND TUB\\t3.99\\t\\n',\n", | |
" '331222\\tDAISY SOUR CREAM\\tPURE & NATURAL\\t3 POUND TUB\\t3.89\\t\\n',\n", | |
" '384962\\tKIRKLAND SIGNATURE\\tUNSALTED BUTTER QTRS\\t4/1 POUND PACKAGES\\t\\t\\n',\n", | |
" '506950\\tHORIZON\\tORGANIC HALF & HALF\\t64 OUNCE CARTON\\t5.99\\t\\n',\n", | |
" '637598\\tKS CAGE FREE EGGS\\tUSDA GRADE AA\\t2 DOZEN\\t3.19\\t\\n',\n", | |
" '843323\\tFRIGO CHEESEHEADS\\tSTRING CHEESE\\t60/1 OUNCE STICKS\\t10.89\\t\\n',\n", | |
" '1048072\\tKIRKLAND SIGNATURE\\tORGANIC NONFAT GREEK\\tYOGURT 3 POUND TUB\\t5.59\\t\\n',\n", | |
" '1056241\\tTROPICANA PURE PREMIUM ORANGE JUICE\\t3/59 OUNCE BOTTLES\\t8.25\\t\\t\\n',\n", | |
" \"1070683\\tLAND 0' LAKES\\tWHIPPED HEAVY CREAM\\t3/14 OUNCE CANS\\t8.49\\t\\n\",\n", | |
" '1116038\\tKIRKLAND SIGNATURE\\tSHREDDED MOZZARELLA\\t212.5 POUND BAGS\\t12.49\\t\\n',\n", | |
" '1164891\\tSILK\\tORGANIC UNSWEETENED\\tALMOND MILK 3/64 OUNCE\\t8.99\\t\\n',\n", | |
" '1165284\\tKIRKLAND SIGNATURE\\tSHREDDED MEXICAN BLEND\\t2/2.5 POUND BAGS\\t13.99\\t\\n',\n", | |
" '1269739\\tFAGE\\tTOTAL MILKFAT\\tYOGURT 3 POUND TUB\\t5.99\\t\\n',\n", | |
" \"360386\\tWYMAN'S\\tWILD BLUEBERRIES\\t4 POUND BAG\\t8.89\\t\\n\",\n", | |
" '422672\\tMORNINGSTAR FARMS\\tVEGGIE SAUSAGE PATTIES\\t2.675 POUND BOX\\t13.99\\t\\n',\n", | |
" '457883\\tWATTS BROTHERS\\tORGANIC MIXED VEGGIES\\t5 POUND BAG\\t6.99\\t\\n',\n", | |
" '904984\\tKIRKLAND SIGNATURE\\tORGANIC STRAWBERRIES\\t4 POUND BAG\\t10.59\\t\\n',\n", | |
" '948400\\tKIRKLAND SIGNATURE\\tVANILLA ICE CREAM\\t2 - HALF GALLON\\t12.99\\t\\n',\n", | |
" '1010598\\tKIRKLAND SIGNATURE\\tTHREE BERRY BLEND\\t4 POUND BAG\\t8.99\\t\\n',\n", | |
" '1075250\\tPERDUE\\tCHICKEN BREAST\\t10 POUND BAG\\t22.49\\t\\n',\n", | |
" '1160766\\tDIAMOND VALLEY\\tHALAL GROUND BEEF\\t4/1 POUND PACKAGES\\t15.99\\t\\n',\n", | |
" '1215095\\tKIRKLAND SIGNATURE\\tORGANIC YELLOW CORN\\t5 POUND BAG\\t7.49\\t\\n',\n", | |
" '1215097\\tKIRKLAND SIGNATURE\\tORGANIC PEAS\\t5 POUND BAG\\t7.49\\t\\n',\n", | |
" '1304231\\tKIRKLAND SIGNATURE\\tANGUS CHUCK PATTIES\\t6 POUND BAG\\t18.99\\t\\n',\n", | |
" '7859\\tFOPPEN\\tSMOKED SALMON SLICES\\t12 OUNCE PACKAGE\\t10.79\\t\\n',\n", | |
" '9090\\tKIRKLAND SIGNATURE\\tGOAT CHEESE\\t2/10.5 OUNCE PACKAGES\\t6.59\\t\\n',\n", | |
" '26802\\tPRESIDENT\\tCRUMBLED FETA\\t24 OUNCE CONTAINER\\t7.49\\t\\n',\n", | |
" '32868\\tSABRA\\tHUMMUS WITH PINE NUTS\\t32 OUNCE CONTAINER\\t5.99\\t\\n',\n", | |
" '36275\\tKIRKLAND SIGNATURE\\tSLICED ROAST BEEF\\tPRICE PER POUND\\t7.49\\t\\n',\n", | |
" '48600\\tKIRKLAND SIGNATURE\\tABF ROASTED TURKEY\\tPRICE PER POUND\\t6.79\\t\\n',\n", | |
" '48602\\tKIRKLAND SIGNATURE\\tBLACK FOREST HAM\\tPRICE PER POUND\\t4.99\\t\\n',\n", | |
" '99006\\tJARLSBERG\\tNORWEGIAN SWISS\\tPRICE PER POUND\\t5.55\\t\\n',\n", | |
" '186626\\tKIRKLAND SIGNATURE\\tSHREDDED PARM REGGIANO \\t16 OUNCE CONTAINER\\t12.99\\t\\n',\n", | |
" '214593\\tBASHA\\tORIGINAL HOMMUS\\t38 OUNCE CONTAINER\\t4.89\\t\\n',\n", | |
" '623762\\tCOSMOS\\tKIMCHI\\t58 OUNCE CONTAINER\\t7.99\\t\\n',\n", | |
" '709616\\tGAROFALO\\tBUFALA MOZZARELLA\\t17.6 OUNCE CONTAINER\\t11.99\\t\\n',\n", | |
" '1204135\\tHOUSE FOODS\\tORGANIC FIRM TOFU\\t4/16 OUNCE PACKAGES\\t4.99\\t\\n',\n", | |
" '617686\\tSOFTSOAP\\tADVANCED CLEAN SOAP\\t \\t8.99\\t\\n',\n", | |
" '55992\\tFRESH GROUND TURKEY\\tLEAN/ FAT\\tPER LB.\\t2.59\\t\\n',\n", | |
" '69509\\tGROUND BEEF PATTIES\\t88% LEAN / FAT\\tPER LB\\t2.89\\t\\n',\n", | |
" '412\\tORGANIC\\tPEELED CARROTS\\t2/2LB BAGS\\t5.49\\t\\n',\n", | |
" '2619\\tORGANIC BANANAS\\t3 LBS.\\t1.82\\t\\t\\n',\n", | |
" '4032\\tWATERMELON\\tSEEDLESS\\tEACH\\t5.69\\t\\n',\n", | |
" '5685\\tSPINACH\\t2.5 LBS\\t4.99\\t\\t\\n',\n", | |
" '9876\\tBROCCOLI FLORETS\\tORGANIC\\t3 LBS\\t6.99\\t\\n',\n", | |
" '18600\\tCLEMENTINES\\t5 LBS\\t7.99\\t\\t\\n',\n", | |
" '21020\\tCLUSTER TOMATOES\\tGREENHOUSE GROWN\\t4 LBS\\t6.99\\t\\n',\n", | |
" '24587\\tORGANIC ROMAINE HEARTS\\t6 COUNT\\t5.99\\t\\t\\n',\n", | |
" '25949\\tCOLOSSAL GARLIC\\t2 LB BAG\\t5.49\\t\\t\\n',\n", | |
" '27003\\tSTRAWBERRIES\\t2 LB CLAMSHELL\\t3.79\\t\\t\\n',\n", | |
" '30669\\tBANANAS\\tPREMIUM FIRST QUALITY\\t3 LBS.\\t1.24\\t\\n',\n", | |
" '31410\\tGOLD POTATOES\\t15 LBS\\t7.99\\t\\t\\n',\n", | |
" '39036\\tHEARTS OF ROMAINE\\t6 COUNT\\t3.69\\t\\t\\n',\n", | |
" '47497\\tORANGES\\t13 LBS.\\t10.99\\t\\t\\n',\n", | |
" '56366\\tRASPBERRIES\\t12 OZ CLAMSHELL\\t3.99\\t\\t\\n',\n", | |
" '57554\\tBLUEBERRIES\\t18 OZ CLAMSHELL\\t3.69\\t\\t\\n',\n", | |
" '60357\\tMIXED BELL PEPPERS\\t6 COUNT\\t5.99\\t\\t\\n',\n", | |
" '67245\\tYELLOW ONIONS\\tJUMBO\\t10 LBS.\\t5.99\\t\\n',\n", | |
" '77053\\tGRAPE TOMATOES\\tGREENHOUSE GROWN\\t2 LBS.\\t4.99\\t\\n',\n", | |
" '80487\\tBRUSSELS SPROUTS\\t \\t2 LB.\\t\\t\\n',\n", | |
" '83333\\tGREEN GRAPES\\tSEEDLESS\\t4 LBS\\t6.29\\t\\n',\n", | |
" '83337\\tRED GRAPES\\tSEEDLESS\\t4 LBS\\t5.49\\t\\n',\n", | |
" '83345\\tLEMONS\\tFANCY\\t5 LBS\\t6.39\\t\\n',\n", | |
" '88402\\tCELERY STICKS\\t2.5 POUND BAG\\t3.49\\t\\t\\n',\n", | |
" '113523\\tORGANIC MUSHROOMS\\tPREMIUM LARGE WHITE\\tnoz\\t4.99\\t\\n',\n", | |
" '519638\\tORGANIC BLUEBERRIES\\t18 OZ CLAMSHELL\\t8.49\\t\\t\\n',\n", | |
" '568915\\tORGANIC LONG ENGLISH\\tCUCUMBERS\\tGREENHOUSE GROWN 3PACK\\t\\t\\n',\n", | |
" '647465\\tAVOCADO\\tHASS VARIETY\\t6 COUNT\\t\\t\\n',\n", | |
" '675153\\tSWEET KALE SALAD\\t28 OUNCE\\t4. 99\\t\\t\\n',\n", | |
" '782294\\tORGANIC POWER GREENS\\t1.5 LBS.\\t5.99\\t\\t\\n',\n", | |
" '910853\\tORGANIC LIMES\\tPRODUCT OF MEXICO\\t5 LB. BAG\\t6.99\\t\\n',\n", | |
" '969425\\tORGANIC GALA APPLES\\tNEW CROP\\t5.5 LBS\\t\\t\\n',\n", | |
" '1074586\\tSUGAR SNAP PEAS\\t24 OZ BAG\\t4.79\\t\\t\\n',\n", | |
" '1121095\\tORGANIC\\tRAINBOW CARROTS\\t5 LBS\\t5.99\\t\\n']" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"nlines" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"file = open('costco_inventory.csv', 'w')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"file.writelines(nlines)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment