text:
<file_sep>
import sqlite3
import sys
import time

# print time.ctime() + "--- import sqlite3 - success"
# print time.ctime() + "--- import sys - success"
# print time.ctime() + "--- import time - success"

con = None
inPath = "C:\Users\langfeldn\Desktop\TEMP\\20170104 - Jungfernstieg\\"
inFile = "v67_k1.db"
inMain = inPath + inFile

print inFile

## SELECTS
sel_1 = "SELECT Reason, sum(LCOUNT_Numerator), sum(LCOUNT_denominator),count(*) FROM FRESH_COUNTS group by REASON;"
sel_2 = "SELECT datetime(substr(creation_time,1,10), 'unixepoch') , datetime(substr(timeofinput,1,10), 'unixepoch') , *  FROM FRESH_COUNTS order by timeofinput;"
sel_3 = "SELECT datetime(substr(creation_time,1,10), 'unixepoch') , datetime(substr(timeofinput,1,10), 'unixepoch') , *  FROM FRESH_COUNTS WHERE REASON = 'ADD_STORNO' order by timeofinput;"
sel_4 = "SELECT count(*) , Reason  FROM FRESH_COUNTS group by REASON;"
sel_5 = "SELECT datetime(substr(creation_time,1,10), 'unixepoch') , datetime(substr(timeofinput,1,10), 'unixepoch') , *  FROM FRESH_COUNTS WHERE REASON = 'DWINDLING' order by timeofinput;"
sel_6 = "SELECT datetime(substr(creation_time,1,10), 'unixepoch') , datetime(substr(timeofinput,1,10), 'unixepoch') , *  FROM FRESH_COUNTS WHERE REASON = 'NVKWARE' order by timeofinput;"
sel_7 = "select ITEM_ID, ITEM_Number, NAME_Real from ART_SALES_ITEM_HIST where ITEM_ID in (2123, 1221, 1141, 308) ;"
sel_8 = "SELECT LARTICLEID,  LCOUNT_NUMERATOR,  LCOUNT_DENOMINATOR,  REASON,  CREATION_TIME,  TIMEOFINPUT,  VOUCHER_ID,  CANCELED_VOUCHER_ID,  POSITION,  CASH_NO,  ISRESETCOUNT,  LREALARTIKELID FROM FRESH_COUNTS f1 WHERE f1.REASON NOT IN ('ADD_STORNO','SELL_STORNO') AND f1.VOUCHER_ID NOT IN( SELECT  CANCELED_VOUCHER_ID FROM FRESH_COUNTS f2 WHERE f2.REASON IN ('ADD_STORNO','SELL_STORNO') AND CANCELED_VOUCHER_ID IS NOT NULL ) ORDER BY CREATION_TIME ASC ; "

try:
    con = sqlite3.connect(inMain)

    useSelect = sel_3
    print useSelect

    cur = con.cursor()
    cur.execute(useSelect)

    data = cur.fetchall()
    for entry in data: print entry
##    for entry in data: print entry[1] + " ... " + entry[8] + " ... {} ".format(entry[13])

except sqlite3.Error, e:
    print "Error %s:" % e.args[0]
    sys.exit(1)

finally:
    if con: con.close()

<file_sep># coding=utf-8
# Dieses Skript soll aus allen möglichen Dreieckskombinationen einer Punktwolke, die optimale Verteilung ermitteln
# Hier gibt es zwei Möglichkeiten für das Optimum.
#   1) Das Maximum der Summe aller Flächen (Summe Flächen)
#   2) Das Maximum aller Flächen (Anzahl Flächen)

<file_sep># coding=utf-8
# Das Skrtipt soll Punkte im Raum visualisieren
# im Ersten Schritt lediglich in 2D
# im letzten Schritt, wäre eine Sarstellung der Höheninformationen wünschenswert<file_sep># coding=utf-8
# Dieses Skript soll alle möglichen Dreiecke ermitteln<file_sep>
def sumNumInString(inStr):
    splitStr = inStr.split(',')
    sum = 0
    cNum = 0
    for num in splitStr:
        try:
            num = int(num)
            print "Element = {} Type: {}".format(num, type(num))
            sum = sum + num
            cNum = cNum + 1
        except ValueError: continue

    print "{} Nummern gefunden".format(cNum)
    print "Ergeben eine Summe von {}".format(sum)

def createStatement(pre,suf,val,multi):
    strOut = pre + (val*multi) + suf
    print strOut

createStatement('mygrid.setColAlign("', '");', 'true,', 45-19)
createStatement('mygrid.setColTypes("', '");', 'edtxt,', 45)
createStatement('mygrid.setColSorting("', '");', 'str,', 45)

inStr ='8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6'
#sumNumInString(inStr)

inStr ='0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,20, 20, 10, 10, 5,20,5, 5, 5, 20,5, 5, 5, 5, 5, 5, 5'
#sumNumInString(inStr)

<file_sep># Verarbeitung Logfiles

# ABLAUF - DETAIL -----------------------------
# 1) Logfile einlesen
# 2) Ermittlung von Shop und Kasse
#       > v201_k1
# 3) Ermittlung von Start und Ende
#       > 20170401103546_20170403030734
# 4) Speicherung des Logfiles unter dem neuen Namen
#       > v201_k1_20170401103546_20170403030734.txt

## IMPORT --------------------------------------------------
import time
import os
from distutils.ccompiler import new_compiler

## METHODEN ------------------------------------------------

## LOGGER
def log(text):
    print time.ctime() + ' --- ' + text

## SCANNER
def scanFile(fullFileName):
    fo = open(fullFileName,'r')
    data = fo.readlines()
    fo.close()
    id = extractID(data)
    time = extractTime(data)
    try:
        final = id + '_' + time
        return final
    except TypeError:
        return ''

# EXTRACTER TIME
def extractTime(data):
    times = []
    for entry in data:
        try:
            dataSplit = entry.split(' ')
            timestamp = dataSplit[0] + ' ' + dataSplit[1]
            #print timestamp          # Ausgabe funktioniert
            fTime = formatTimestamp(timestamp)
            #print fTime
            times.append(fTime)

        except IndexError:
            break

        t_start = times[0]
        t_end = times[times.__len__() - 1]
        extractedTime =  t_start + '_' + t_end
        return extractedTime

def formatTimestamp(timestampIn):
# hier bitte einen Zeitstempel in folgendem Format eingeben
# 15.05.2017 11:05:29:387

        tsSplit = timestampIn.split('.')
# Im ersten Schritt ziehen wir das Datum raus und wandeln es in yyyymmdd um
        dateOut = tsSplit[2].split(' ')[0]+tsSplit[1]+tsSplit[0]
# Im zweiten Schritt ziehen wir die Zeit raus und wandeln diese in HHMM um
        timeTemp = tsSplit[2].split(' ')[1]
        tempSplit = timeTemp.split(':')
        timeOut = tempSplit[0]+tempSplit[1]+tempSplit[2]
        return dateOut+timeOut

# EXTRACTER - ID
def extractID(data):
    hit00 = 0
    hit01 = 0
    hit02 = 0
    hit03 = 0

    for entry in data:
        entry = entry.rstrip()
        hit00 = entry.find('Created new vouche ')
        if hit00 > 0:
            hit01 = entry.find('v', hit00+15)
            newEntry = entry[hit01:]
            hit02 = newEntry.find('_')
            hit03 = newEntry[hit02+1:].find('_')
            id = newEntry[0:hit02+hit03+1]
            return id

def checkFileExist(searchPath, searchFile):
    fileList = os.listdir(searchPath)
    bool_exist = False
    for file in fileList:
        if file == searchFile:
            bool_exist = True
    return bool_exist

# --- MAIN ------------------------------------------

log('START')

str_cwd = os.getcwd()
print '\t Aktuelles Verezeichnis: ' + str_cwd

log('Verzeichniswechsel')

newPath = "C:\Users\langfeldn\Downloads"
os.chdir(newPath)
str_cwd = os.getcwd()
print '\t Aktuelles Verezeichnis: ' + str_cwd
if newPath == str_cwd: print '\t Success'

## Scannen nach Textdateien
log('Scannen nach Textdateien')
fileList = os.listdir(str_cwd)
new_fileList = []
logFileList = []
for file in fileList:
    if file.find('.txt') > 0 :
        new_fileList.append(str_cwd+'\\'+file)

log('Scannen nach Logdateien')
for file in new_fileList:
    if file.find('Log') > 0 :
        logFileList.append(file)

#newFileCollector = []
for logfile in logFileList:
    id = scanFile(logfile)
    if id.__len__() > 10:
        try:
            newFileName = id + '.txt'
            nfn = newPath + '\\' + newFileName
            if checkFileExist(newPath,newFileName)== True:
                print nfn
                print 'EXISTS'
            if checkFileExist(newPath, newFileName) == False:
                print nfn
                print 'NOT EXISTS'
                os.renames(logfile, nfn)

        except TypeError:
            break

print nfn
log('ENDE')<file_sep>## --- ANALYSE FEHLENDER VERK?UFE -------------------
##
## In Polen ist es vorgekommen, dass Belege von der Kasse
## angelegt wurde und auch vom Fiscaldrucker gedruckt wurden.
## Diese Belege wurden jedoch nicht von der Kasse gespeichert
## oder gebucht und tauchten somit nicht im Server/Datenabnk auf.

## WORKFLOW
## 1) ORdner Suchen
## 2) alles scannen, was enthalten ist
## 3) Alle Daten wegschreiben und wirgendwie ordnen
## 4) Daten auswerten
##  4.1) Ermittlung des Zeitstempels
##  4.2) Ermittlung des Beleges
##  4.3) Ermittlung, ob der Beleg auch final erzeugt wurde
##      -- Das sollte sich wiederrum auch aus dem Kassenlog ermitteln lasse.
##      -- Vielleicht sollte man dann einfach f?r jede Kasse eine neue Liste schaffen
##      -- Es gibt ja Kassen, die sowhol erzeugen als auch empfangen
##      -- Es gibt aber auch Kassen, die nur empfangen

##  Der Logik nach sollte ja ein Beleg, der auf einer Kasse defeinitiv erzeugt wurde,
##  auch auf die anderen Kassen kommuniziert werden.

## IMPORT ------------------------------------------
import os
import time

## METHODEN ------------------------------------------

analyseDir = ''

os.chdir(analyseDir);
print(os.getcwd())
fileList = []               ## INIT FLIST
fileList = getAllFiles

def getAllFiles(curDir):
    fList = []
    fList = os.listdir(curDir)
    return fList

<file_sep>### ------------------------------------------------------------------------
##      SCAN4NPE.PY
##      - mit diesem Skript soll eine Reihe von Dateien gescannt werde
##      - Es soll ermittelt werden, ob und wann eine NPE aufgetreten ist
##      - Zusaetzlich soll f?r das Logfile der Shop und die jeweilige Kasse ermittelt werden
### ------------------------------------------------------------------------

## IMPORT
import time
import os

## METHODEN

def findNPE(in_str):
    searchStr01 = 'NullPointerException'
    searchStr02 = "Starting"

    if in_str.find(searchStr01) > 0:
        print(in_str)
    if in_str.find(searchStr02) > 0:
        print(in_str)

## START -------------------------------------------------------------------------------------------------
print time.ctime() + " --- START"

## LIST ALL FILES CONTAINING IN THE CURFOLDER
#path = "C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANIKA\ANALYSE\\20160622_v248_Kartenzahlung"
#path = 'C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANIKA\ANALYSE\\20160715 - B-Hbf-Kartenzahlung\ANALYSE'
path = raw_input('Bitte Ordner angeben!\n')

os.chdir(path)
curDir = os.getcwd();
fileList = os.listdir(curDir);

print "\n{} Dateien gefunden".format((len(fileList)))
# ---------------------------------------------------------------------------------------------------------

for item in fileList:
    print " " + item
    finPath = path+"\\"+item
    fopen = open(finPath ,'r')
    data = fopen.readlines();
    lineCount = len(data)
    fopen.close()
    print "VERARBEITUNG >> "

    for line in data:
        findNPE(line.rstrip())

    print "Es wurden {} Zeilen verarbeitet\n".format(lineCount);

    print time.ctime() + " --- ENDE "

<file_sep>

## Einlesen der Files

import os
import time

path = raw_input("Working Directory:\n")
os.chdir(path)
if path == os.getcwd(): print "success"
    ### perfekt bis hier laeuft es

## Dateien ermitteln
allList = os.listdir(path)
fileList = []

for entry in allList:
    if entry.find("mqtt") <> -1 :
        print entry
        fileList.append(entry)

for entry in fileList:
    fullPath = path + '\\' + entry
    print "\n"+fullPath

    # init counter
    c1 = c2 = c3 = c4 = c5 = 0

    fopen = open(fullPath,'r')
    data = fopen.readlines()
    for item in data:
        item = item.rstrip()
        if item.find("MessageArrived") > -1 :
            if item.find("STORNO_SALE_VOUCHER") > -1:
                c1 = c1 + 1
            if item.find("DO_FRESH_POST") > -1:
                c2 = c2 + 1
            if item.find("DO_DWINDLING") > -1:
                c3 = c3 + 1
            if item.find("DO_FRESH_FRACTION_DWINDLING") > -1:
                c4 = c4 + 1
            if item.find("SELL_SALE_VOUCHER") > -1:
                c5 = c5 + 1

    print "{} - {}".format("SELL_SALES_VOUCHER", c5)
    print "{} - {}".format("STORNO_SALE_VOUCHER", c1)
    print "{} - {}".format("DO_FRESH_POST", c2)
    print "{} - {}".format("DO_DWINDLING", c3)
    print "{} - {}".format("DO_FRESH_FRACTION_DWINDLING", c4)

    fopen.close()

#"rpcmethod":"DO_FRESH_POST"

#   - Obtained SELL_SALES_VOUCHER:
#   - parsing message type: STORNO_SALE_VOUCHER
#   - parsing message type: DO_FRESH_POST
#   - parsing message type: DO_DWINDLING
#   - parsing message type: DO_FRESH_FRACTION_DWINDLING
<file_sep>import os
import time
#import subprocess as sp

# METHODEN ------------------------------
from unittest import result

def ping(host):
    #host = 'google.de'
    result = os.popen("ping -n 2 " + host).read()
    res_Split = result.split(' ')
    #for entry in res_Split:
    #    print entry
    if result.find("ms") > -1: print ("\t{} >>> SUCCESS".format(host))
    else: print ("\t{} >>> FAIL".format(host))

print (time.ctime() + ' ---- START ----------------')

ping("google.de")
ping("waserbuefl")
ping("172.30.28.151")
ping("SG-HHW019")
ping("lcb-dex-scan.lecrobag.de")

print (time.ctime() + ' ---- ENDE ----------------')

<file_sep>## Quadrantenlogik
#
# | dx | dy | Quad
# | +  | +  | 1     + 0gon
# | +  | -  | 2     + 200gon
# | -  | -  | 3     + 200gon
# | -  | +  | 4     + 400gon

import math

## Berechnung der Strecke zwischen zwei Punkten

# Punkt 1
x1 = 0
y1 = 0

# Punkt 1
x2 = 2
y2 = 0

## Calc
# calc deltas
dy = y2 - y1
dx = x2 - x1

s = math.tan(dy/dx)/(math.pi*360)
# dieser Werte m?sste nun in Grad ausgegeben werden

print "Punkt 1 : [ {:.2f} | {:.2f} ] ".format(float(x1),float(y1))
print "Punkt 2 : [ {:.2f} | {:.2f} ] ".format(float(x2),float(y2))
print "DeltaX  : {:.2f} ".format(float(dx))
print "DeltaY  : {:.2f} ".format(float(dy))
print "riwi    : {:.2f} ".format(float(s))

## Quadrantenlogik
#
# | dx | dy | Quad
# | +  | +  | 1
# | +  | -  | 2
# | -  | -  | 3
# | -  | +  | 4

<file_sep># FIND INVENTURKAUDAWELSCH

suchString = 'Exiting CSPDBInventory::lastTimeStamp: retVal = null'

# open file

path = 'C:\\Users\\langfeldn\\Desktop\\'
filename = 'test.txt'

fileMain = path + filename

fopen = open(fileMain,'r')
data = fopen.readlines();

for entry in data:
    dataSplit = entry.split(' ')
    timestamp = dataSplit[0]
    hit = ''
    for i in dataSplit:
        c = i.find('CSPDBInventory')
        if c > -1 :  hit = i
    print timestamp + ' --- ' + hit
    # print entry

<file_sep>#!/usr/bin/python
# -*- coding: ascii -*-

##
# Dieses Skript dient dazu, Logs zu mergen

##  ABLAUF -----------------------------------------------
#   1) Beide Dateien laden
#   2) beide Dateien auslesen
#   3) beide Dateien in eine Liste schreiben
#   4) Liste nach Zeitstempel ordnen
#   5) Geordnete Liste in eine neue Datei schreiben

## -------------------------------------------------------
## IMPORT

from datetime import datetime
import os

f01 = "C:\Users\langfeldn\Downloads\\input.log.2017-03-06"         # INPUT.LOG
f02 = "C:\Users\langfeldn\Downloads\\input.log.2017-03-05"         # VIDEO.LOG
path = "C:\Users\langfeldn\Downloads\\"

fopen01 = open(f01,'r')
fopen02 = open(f02,'r')

data01 = fopen01.readlines()
data02 = fopen02.readlines()

print "Zeilen: {}".format(len(data01))
print "Zeilen: {}".format(len(data02))

##  DATENVERARBEITUNG ----------------------------------------
data = data01 + data02                              # alle beiden Datens?tze mergen
#print "Zeilen: {}".format(len(data))

newList = []                    # Erzeugung einer leeren Liste
counter = 0
        # Schleife ?ber alle Elemente in der DATA
        # Zeilenumbruch mit rstrip entfernen
        # Element spliten
        # Datum umwandeln
        # Werte an Liste anh?ngen

for hit in data:
    test = hit.rstrip()
    try:
        temp = test.split(' [INFO] ')
        temp[0] = datetime.strptime(temp[0], '%Y-%m-%d %H:%M:%S.%f')
        newList.append(temp)
        counter = counter + 1
    except: continue

## SORTIERUNG ---------------------------------------------------------
newList.sort()

## VERZEICHNISWECHSEL -------------------------------------------------
os.chdir(path)

## AUSGABE ------------------------------------------------------------
outfile = path + 'out.txt'
fopen = open(outfile,'w')

for item in newList:
    # Formatierte Ausgabe  aller Werte
    fopen.write(item[0].strftime('%Y-%m-%d %H:%M:%S.%f') + ' ' + item[1] + '\n')

## DATEIEN SCHLIESSEN -------------------------------------------------
fopen.close()
fopen01.close()
fopen02.close()
<file_sep>'''
# Ask the user to type in their name an store it in a  variable named "name"

# Create a variable
name = str(raw_input('What is your name? \n'))

# Print out hello followed by the enetered Name
print 'Hello ', name

# -------------------------------------------------------------------------

# Ask the user to input 2 values and store them in variable num1 and num2
#

print "INPUT ----------------------"
num1 = raw_input("Num1 = ");
num2 = raw_input("Num2 = ");

# Convert Strings into Integer
num1_int = int(num1)
num2_int = int(num2)

print "OUTPUT ----------------------"

# Add the values an store in sum
sum = 0
sum = num1_int + num2_int
print str(num1_int) + " + " + str(num2_int) + " = " + str(sum);

# substract both values and store in diff
diff = 0
diff = num1_int - num2_int
print str(num1_int) + " - " + str(num2_int) + " = " + str(diff);

# multiply both values and store in product
product = 0
product = num1_int * num2_int
print str(num1_int) + " * " + str(num2_int) + " = " + str(product);

# divide both values and store in qoutient
qoutient = 0
qoutient = num1_int / num2_int
print str(num1_int) + " / " + str(num2_int) + " = " + str(qoutient);

# use modulus and store in remainder
remainder = 0
remainder = num1_int % num2_int
print str(num1_int) + " % " + str(num2_int) + " = " + str(remainder);

print "\nOUTPUT - FORMATED ----------------------"

print "{} + {} = {} ".format(num1,num2,sum)
print "{} - {} = {} ".format(num1,num2,diff)
print "{} * {} = {} ".format(num1,num2,product)
print "{} / {} = {} ".format(num1,num2,qoutient)
print "{} % {} = {} ".format(num1,num2,remainder)

# ---------------------------------------------------------------
# Problem 1 : Recieve miles and convert to kilometers

# kilometers = miles * 1.60934
# Enter miles = 5
# 5 miles equals 8.04 kilometers

# 1) Inupt number
miles = raw_input("Enter the miles: ")

# 2) convert string to integer
miles = int(miles)

# 3) calc kilometer
kilometers = miles * 1.60934

# 4) print an screen
print "{} miles equals {} kilometers".format(miles,kilometers)

# ---------------------------------------------------------------
# Problem 2 : Buliding a calculator

# Enter calculation: 5 * 6
# 5 * 6 = 30

# 1) store the user input of 2 values
input_calc = raw_input("Enter Calculation: ");

# 2) convert to int
values = input_calc.split()
num1 = int(values[0])
num2 = int(values[2])

result = 0
# 3) if + then we need to provide output based on addition
if values[1] == "+":
    result = num1 + num2
elif values[1] == "-":
    result = num1 - num2
elif values[1] == "*":
    result = num1 * num2
elif values[1] == "/":
    result = num1 / num2
elif values[1] == "%":
    result = num1 % num2
else:
    print "Use either + - * or / next time"

# 4) print result
print "num1 = " + str(num1)
print "num2 = " + str(num2)
print "{} = {}".format(input_calc,result)

# ---------------------------------------------------------------
# Problem 3 : different output based on age

# 1 - 18 -> Important
# 21, 50, > 65 -> Important
# All others -> Not important

# Recieve age an store in age
age = 0
age = int(raw_input("Enter an age: "));

# if age is BOTH greater than or equal to 1 and less than or equal to 18 -> Important
# age >= 1
# age <= 18
# >>> Important

## MY LOGIC
 if age >= 1 and age <= 18: print "IMPORTANT"
 elif age == 21 or age == 50: print "IMPROTANT"
 else: print "Not Important"

# if age is either 21 or 50 >>> IMPORTANT

# WE check if age is less than 65 and then convert true to false and vice versa

# Else "Not Important" << should used as default

'''

# ---------------------------------------------------------------
# Problem 4 : Sending to somewhere based on age

# if age is 5 go to kindergarten
# ages 6 throught 17 goes to grades 1 through 12
# if age ist greater then 17 say go to collega
# try to complete in 10 or less lines

age = eval(raw_input("Enter age: "))
if age == 5:                    print "Go to Kindergarten"
elif age < 5:                   print "Too young for school"
elif age >= 6 and age <= 17:
    print "Go to grade " + str(age -5)
elif age > 17:                  print "Go to college"
else: print "Nothing to say :)"

<file_sep>## Das Skript dient der Kontrolle der Kartenzahlung

# File einlesen
# Betraege raussuchen
# summieren

# 1)
import new
import os

# ---------------------------------------------------------------------
# 1) File einlesen - Dateien ermitteln
from cgitb import enable

os.chdir('C:\Users\langfeldn\Desktop\TEMP\\20170522 - B-Hauptbahnhof - KAZA')
dirList = os.listdir(os.getcwd())
newList = []

# hier filter wir die ZIPs raus und behalten die logdateien
for hit in dirList:
    if hit.find('.zip')<0:newList.append(hit)

print newList

# ---------------------------------------------------------------------
# 1.1) Dateien einlesen

print 'DATA READING > START'

fileobj = open(newList[0],'r')
data1 = fileobj.readlines()
fileobj.close()

fileobj = open(newList[1],'r')
data2 = fileobj.readlines()
fileobj.close()

print 'DATA READING > DONE'

# ---------------------------------------------------------------------
# 2) Betraege raussuchen

date = []
info = []
amount = []

for line in data1:
    line = line.rstrip()
    if line.find('INSERT OR REPLACE INTO CARD_PAYMENTPARTS') > 0:
        splitLine = line.split(',')
        info_ = splitLine[26]
        date_ = splitLine[0]
        amount_ = splitLine[27]

        # Bereingung INFO
        idx = info_.find('v')
        info_ = info_[idx:]

        # BEREINGUNG DATE
        date_ = date_[:19]

        date.append(date_)
        info.append(info_)
        amount.append(amount_)

        print "{} - {} - {}".format(date_,info_,amount_)

#allList = [[date],[info],[amount]]
#print allList
#allList.sort()
#print allList

c = 0;
for hit in splitLine:
    print "[{}]  - {}".format(c,hit)
    c = c + 1;
<file_sep>## SCAN INPUT LOG

import time, os
from dircache import listdir

def log(text):
    import time
    print(time.ctime() + ' --- ' + text)

def changeDir():
    print ('Aktuelles Verzeichnis:\t\t\t' + os.getcwd())
    s_input = raw_input('Bitte Verzeichnis angeben:\t\t')
    os.chdir(s_input)
    print ('Aktuelles Verzeichnis:\t\t\t' + os.getcwd())
    return s_input

## MAIN ---------------------------------------------------------------------------------

searchStr01 = 'InputDialog Button'
searchStr02 = 'FreshVoucherList'
searchStr03 = 'StornoDialog'

strings = ['InputDialog','FreshVoucherList','StornoDialog','GoodsSelectionFragment', 'VoucheHistoryFragmentDialog', 'Schwundauswahl' ]

#path = changeDir()
#list_File = os.listdir(path)                   -- erstmal eine einzelne Datei
filePath = 'C:\Users\langfeldn\Desktop\TEMP\\20170310 - Suedkreuz Kiosk\KASSE 1\input.log'

fopen = open(filePath, 'r')
data = fopen.readlines()
fopen.close()

for item in data:
    treffer = False

    for str in strings:
        if item.find(str) > 5:    treffer = True

    if treffer == False:
        print item.rstrip()

<file_sep>## -----------------------------------------------------------------------
##  PYTHON SKRIPT F?R DIE VERARBEITUNG VON COKE-MOVILIZER-EXPORTS
##
##  ABLAUF:
##  1)  Dateien oder Arbeitsordner w?hlen
##  2)  Dateien importieren
##  3)  Dateien auslesen
##  4)  Dateien verarbeiten
##  5)  Dateien als CSV schreiben
##  6)  Exports in MYSQL-DB einspielen
##  7)  Kontrolle

## -----------------------------------------------------------------------

## -----------------------------------------------------------------------
##  IMPORT

import csv
import time
import os

## -----------------------------------------------------------------------
##  MAIN

print(time.ctime() + " --- " + "START")

print(time.ctime() + " --- " + "IMPORT DATA")

print(time.ctime() + " --- " + "PROCESS DATA")
print(time.ctime() + " --- " + "EXPORT DATA")
print(time.ctime() + " --- " + "DB PROCESS")

print(time.ctime() + " --- " + "ENDE")
<file_sep>import os

def sub(inStr):
    strL = len(inStr)
    subString = inStr[0:strL - 8]
    print subString

print os.getcwd()

dirList = os.listdir(os.getcwd())

for item in dirList:
    sub(item)

# stringTest =  "Dateiname.EndungChecksum"

<file_sep>### ------------------------------------------------------------------------
##      OPENFILE.PY
##      - hier soll eine Datei eingelesen werden, und die Stellen herausgesucht werden, die einen
##        HEX-String enthlaten
##      - Am Ende soll ausgegeben werden, wie viele Zeile gelesen wurden
### ------------------------------------------------------------------------

## IMPORT
import time
import os

## METHODEN
def hex2ascii(in_str):
    import binascii
    splitRes = in_str.split(' ');
    newString = ""          # neuen leeren String angelegt
    #list = [hex(06),hex('0F'),hex(29),hex('F0')]

    for element in splitRes:
        if element > hex(28) and element <> list:
            try:
                if element <> list:
                    hexStr = binascii.a2b_hex(element)
                    newString = newString + hexStr
            except TypeError:
                newString = newString + ''

    return newString

## START
print time.ctime() + " --- START"

## LIST ALL FILES CONTAINING IN THE CURFOLDER
#path = "C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANIKA\ANALYSE\\20160622_v248_Kartenzahlung"
path = 'C:\Users\langfeldn\Desktop\TEMP\\20170620 - Berlin Hbf - Sync\KA1'
os.chdir(path)
curDir = os.getcwd();
fileList = os.listdir(curDir);

print "\n{} Dateien gefunden".format((len(fileList)))

for item in fileList:
    print " " + item

## CHOOSE FILE
choice = raw_input("\nBitte eine Datei angeben.  ")

## CREATE FINAL FILEPATH
finPath = path+"\\"+choice

## OPEN FILE
fopen = open(finPath ,'r')

## READ LINES
data = fopen.readlines();
lines = len(data)

## CLOSE FILE
fopen.close()

## VERABREITUNGSBEREICH

print "VERARBEITUNG >> "
searchStr = "Response starts with"
cleanStr = ""

for line in data:
    if line.find(searchStr) > 0:
        #print line.rstrip()
        line =  line.rstrip()
        cleanStr = line.rsplit(":")[5]
        print cleanStr
        print hex2ascii(cleanStr)

## PRINT RESULT
print "Es wurden {} Zeilen verarbeitet\n".format(lines);

## ENDE
print time.ctime() + " --- ENDEs"

<file_sep>### ------------------------------------------------------------------------
##      SCAN4NPE.PY
##      - mit diesem Skript soll eine Reihe von Dateien gescannt werde
##      - Es soll ermittelt werden, ob und wann eine NPE aufgetreten ist
##      - Zusaetzlich soll f?r das Logfile der Shop und die jeweilige Kasse ermittelt werden
### ------------------------------------------------------------------------

## IMPORT
import time
import os

## METHODEN

def findHIT(in_str):
    strList = [
    'Created new vouche id',
    "NEW_SALES_DATA",
    "FreshInputFragment requested VoucheId",
    "Stub::IAccountingRPC:doDwindling:",
    "doInPaymentWithCurrencies",
    "doOutPaymentWithCurrencies",
    "doClosePaymentWithCurrencies",
    "BillingBillFragment requested VoucheId:",
    "ConfirmDialog requested VoucheId:",
    "BillingArticlesFragment requested VoucheId:",
    "BillingPaymentFragment requested VoucheId: "
    ]

    bl_hit = False

    if in_str.find(strList) > 0:
        bl_hit = True

    if bl_hit == True:  return in_str
    if bl_hit == False: return ""

## START -------------------------------------------------------------------------------------------------
print time.ctime() + " --- START"

## LIST ALL FILES CONTAINING IN THE CURFOLDER
path = raw_input('Bitte Ordner angeben!\n')

os.chdir(path)
curDir = os.getcwd();
fileList = os.listdir(curDir);

print "\n{} Dateien gefunden".format((len(fileList)))
# ---------------------------------------------------------------------------------------------------------

for item in fileList:

    # Reading File/s
    print " " + item
    finPath = path+"\\"+item
    fopen = open(finPath ,'r')

    # Accessing Data
    data = fopen.readlines();
    lineCount = len(data)
    fopen.close()

    # Start Verarbeitung
    print "VERARBEITUNG >> "

    # Anlage tempListe
    outList = []

    # Verarbeitung
    for line in data:
        output = findHIT(line.rstrip())
        if len(output) > 0:
            outList.append(output)

    print "Liste hat {} Eintraege".format(len(outList))
    c = 0                                       # Counter initiieren
    searchStr01 = 'Created new vouche id'       # SearchString initiieren

    for entry in outList:
        if c == 0:
            c = c + 1
            continue
        else:
            if outList[c].find(searchStr01) > 0 and outList[c-1].find(searchStr01) > 0:
                    print outList[c-1]
            c = c + 1

    print "Es wurden {} Zeilen verarbeitet\n".format(lineCount);

    print time.ctime() + " --- ENDE "

<file_sep># 1) Einlesen der detuschen XML
# 2) Einlesen der Übersetzung
# 3) Abgleich der beiden Daten und<file_sep>import os
import time

def log(text):
    str = '<p>' + time.ctime() + ' --- ' + text + '</p>'
    return str

def newParag(text):
    str = "<p>" + text + "</p>"
    return str

# Create file
TITEL = 'DOKUMENTATION - 20170412'

str = "<html><body>"
str = str + "<head><h1>" + TITEL + "</h1></head>"
str = str + log('Start')

str = str + newParag("SELECT * FROM LCBDATA.ANIKA_RESET_FRESH_COUNTS_HIST WHERE lvkeid = 223 order by DAKTUALISIERUNGSDATUM desc;")

str = str + newParag(" 223	4351	5	1	ADD	2017-04-12 13:56:54.000000	2017-04-12 13:56:54.908000	v223_k1_1	(null)	1	1	1	2017-04-12 14:02:28.740598	2017-04-12 00:00:00.000000	52	23")
str = str + newParag(" 733	6	1	ADD	2017-04-12 13:57:04.000000	2017-04-12 13:57:04.923000	v223_k1_2	(null)	1	1	1	2017-04-12 14:02:28.738383	2017-04-12 00:00:00.000000	52	22")
str = str + newParag(" 13575	3	1	ADD	2017-04-12 13:57:26.000000	2017-04-12 13:57:26.683000	v223_k1_3	(null)	1	1	1	2017-04-12 14:02:28.718179	2017-04-12 00:00:00.000000	52	21")

str = str + log('Zwischenstand')
str = str + "<p> Der 24H-Shop funktioniert wie gewuenscht. </p>"

str = str + newParag("-- KONTROLLE ---------------------------------------")
str = str + newParag("SELECT *")
str = str + newParag("FROM LCBDATA.v_be_best")
str = str + newParag("WHERE lvkeid = 223")
str = str + newParag("AND erfdatum > systimestamp - 15;")
str = str + newParag("")
str = str + newParag("SELECT *")
str = str + newParag("FROM LCBDATA.ANIKA_RESET_FRESH_COUNTS_HIST")
str = str + newParag("WHERE lvkeid = 223 order by DAKTUALISIERUNGSDATUM desc;")
str = str + newParag("")
str = str + newParag("-- BEREINIGUNG -------------------------------------")
str = str + newParag("")
str = str + newParag("UPDATE LCBDATA.be_best")
str = str + newParag("SET erfdatum = TO_DATE('20170401 23:59:59', 'yyyymmdd HH24:mi:ss')")
str = str + newParag("WHERE GBELEGID IN (1211605196, 1211605198, 1211605200, 1211605201, 1211605202, 1211605203);")
str = str + newParag("")
str = str + newParag("DELETE FROM lcbdata.be_best")
str = str + newParag("WHERE GBELEGID IN (1211605204, 1211605206, 1211605270, 1211605272, 1211605274, 1211605275, 1211605276, 1211605277, 1211605306, 1211605308);")
str = str + newParag("")
str = str + newParag("DELETE FROM LCBDATA.ANIKA_RESET_FRESH_COUNTS_HIST")
str = str + newParag("WHERE lvkeid = 223;")

str = str + log('Ende')
str = str + "</body></html>"

fobj = open('C:\Users\langfeldn\Desktop\\20170412.html','w')
fobj.writelines(str)
fobj.close()

<file_sep>import os
import time

def log(text):
    print '{} --- {}'.format(time.ctime(), text)

log('START')

mode = 'work'

if mode == 'private': file = '/home/dbg/Schreibtisch/python/work/KA1/videooutput.log'   #path on private laptop
if mode == 'work': file = 'C:\Users\langfeldn\Desktop\\tmp\KA1\\videooutput.log'   #path on work laptop

file1 = 'C:\Users\langfeldn\Desktop\\tmp\KA2\\videooutput0.log'   #path on work laptop
file2 = 'C:\Users\langfeldn\Desktop\\tmp\KA2\\videooutput1.log'   #path on work laptop
file3 = 'C:\Users\langfeldn\Desktop\\tmp\KA2\\videooutput2.log'   #path on work laptop

fobj = open(file1)
data1 = fobj.readlines()
fobj.close()

fobj = open(file2)
data2 = fobj.readlines()
fobj.close()

fobj = open(file3)
data3 = fobj.readlines()
fobj.close()

data = []
for entry in data1:
    data.append(entry)
for entry in data2:
    data.append(entry)
for entry in data3:
    data.append(entry)

treffer = []
for entry in data:
    if entry.find('Storv') > -1: treffer.append(entry)
    if entry.find('Verkv') > -1: treffer.append(entry)

fobj_write = open(os.getcwd()+'\out.txt','w')
outStr = ""

for entry in treffer:
    data_ = entry.split(' ')
    len_ = len(data_)
    beleg_ = "v{}".format(data_[8].split('v')[1])
    outStr = "{} {} {} {}\n".format(data_[0], data_[1], beleg_, data_[len_-2])
    fobj_write.write(outStr)

fobj_write.close()

log('END')

<file_sep># diese Skript soll eine Datei / mehrere Dateien so umbenennen, dass sie eindeutig unterscheidbar sind.

# 1) File suchen
# 2) File oeffnen
# 3) File auslesen
# 4) Info zu Shop und Kasse finden
# 5) Info zu Start und Ende des Logs finden
# 6) neuen File schreiben im Format
#           v###_k##_yyyymmddhhminss_yyyymmddhhminss.txt

# und los

# -- IMPORT ---------------------------------------------------------------

import time
import os

# -- METHODEN -------------------------------------------------------------

def log(text):
    print time.ctime() + ' --- ' + text

# -- MAIN -----------------------------------------------------------------

log('MAIN - START -------------------------------------')

## 1) File suchen ---------------------------------------------------------
log('Verzeichniswechsel - START')
wohin = raw_input("\tPfad angeben:\t")
os.chdir(wohin)
if wohin == os.getcwd(): log('SUCCESS')
log('Verzeichniswechsel - ENDE')

log('Dateisuche - START')
fileList = os.listdir(wohin)
fileList_new = []

for file in fileList:
    if file.find('.txt')>-1:
        if file.find('Log') > -1:
            fileList_new.append(file)

print "\t{} Logfiles gefunden".format(fileList_new.__len__())
log('Dateisuche - ENDE')

## 2) File oeffnen --------------------------------------------------------
log('Datei oeffnen - START')

file = fileList_new[0];

# ab hier kann das Thema in eine Methode ausgelagert werden --------------------------------------------------
fobj = open(file,'r')

## 3) File auslesen -------------------------------------------------------
log('Daten speichern - START')
data = fobj.readlines()             # alle Zeile in data
log('Daten speichern - ENDE')
fobj.close()
log('Datei oeffnen - ENDE')

## 4) Info zu Shop und Kasse finden ---------------------------------------
## Created new vouche id: v201_k3_535

log('Shop- und Kasseninfos finden - START')
hit_ = ""

for hit in data:
    hit = hit.rstrip()
    if hit.find('Created new vouche id: v') > 0:
        hit_ = hit

        idx = hit_.find(': v')
        hit_ = hit_[idx+2:]

vkeka_info = hit_
idx = vkeka_info.find('_')
idx = vkeka_info.find('_', idx+1)
vkeka_info = vkeka_info[:idx+1]

print '\tErgebnis: ' + vkeka_info
log('Shop- und Kasseninfos finden - ENDE')

## 5) Info zu Start und Ende des Logs finden ------------------------------
# fuer Start und Ende brauchen wir ja eigentlich nur die erste und letzte Zeile

log('Start und Ende finden - START')

start = data[0]
ende = data[data.__len__()-1]

# folgende Variablen brauchen wir somit
year = ""
month = ""
day = ""
hour = ""
minute = ""
second = ""

day = start[0:2]
#print day
month = start[3:5]
#print month
year = start[6:10]
#print year
hour = start[11:13]
#print hour
minute = start[14:16]
#print minute
second = start[17:19]
#print second

#print day + month + year + hour + minute + second
start_ = day + month + year + hour + minute + second
#print  'START ' + start_

day = ende[0:2]
#print day
month = ende[3:5]
#print month
year = ende[6:10]
#print year
hour = ende[11:13]
#print hour
minute = ende[14:16]
#print minute
second = ende[17:19]
#print second

#print day + month + year + hour + minute + second
ende_ = day + month + year + hour + minute + second
#print  'ENDE ' + ende_

log('Start und Ende finden - ENDE')

# 6) neuen File schreiben im Format --------------------------------------

log('Neuen Filenamen erzeugen - START')
newFileName = vkeka_info + start_ + '_' + ende_ + '_Log.txt'
log('Neuen Filenamen erzeugen - ENDE')

# os.path.join(path, filename)
oldFileName = os.path.join(os.getcwd(),file)
newFileName = os.path.join(os.getcwd(),newFileName)

log('Neuen File speichern - START')
# os.rename(newFileName, oldFileName)             # das hier hat nicht funktioniert sicher wegen den Klammern oder derartigen Zeichen

## os.path.isfile('C:\Users\langfeldn\Desktop\TEMP\test\v236_k2_07052017091139_18052017141206_Log.txt')

#print os.path.isfile(oldFileName)
#print os.path.isfile(newFileName)

if os.path.isfile(newFileName) == True:
    print "\t File {} existiert bereits. Es wurde nichts unternommen.".format(newFileName)

if os.path.isfile(newFileName) == False:
    fopen_new = open(newFileName,'w')
    fopen_new.writelines(data)
    fopen_new.close()
    print "\t File {} existiert noch nicht. Die Datei wurde angelegt".format(newFileName)
    os.remove(oldFileName)
    print "\t File {} wurde entfernt".format(oldFileName)

log('Neuen File speichern - ENDE')

## FINALE
log('MAIN - ENDE -------------------------------------')

<file_sep>### ------------------------------------------------------------------------
##      OPENFILE.PY
##      - dient dazu eine Datei einzulesen
##      - Am Ende soll ausgegeben werden, wie viele Zeile gelesen wurden
### ------------------------------------------------------------------------

## IMPORT
import time
import os

## START
print time.ctime() + " --- START"

## LIST ALL FILES CONTAINING IN THE CURFOLDER
path = "C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANIKA\ANALYSE\\20160622_v248_Kartenzahlung"
os.chdir(path)
curDir = os.getcwd();
fileList = os.listdir(curDir);

print "\n{} Dateien gefunden".format((len(fileList)))

for item in fileList:
    print " " + item

## CHOOSE FILE
choice = raw_input("\nBitte eine Datei angeben.  ")

## CREATE FINAL FILEPATH
finPath = path+"\\"+choice

## OPEN FILE
fopen = open(finPath ,'r')

## READ LINES
data = fopen.readlines();
lines = len(data)

## PRINT RESULT
print "Es wurden {} Zeilen eingelesen\n".format(lines);

## ENDE
print time.ctime() + " --- ENDEs"

<file_sep># dieses Skript soll auf Basis einer Punktwolke Dreiecke anzeigen
<file_sep># coding=utf-8
## Ablauflogik
##

## IMPORTS ------------------------------------------------

import math
import time

## METHODEN -----------------------------------------------

def Log(text):
    print time.ctime()+ " --- " + text

def calcPointDist(x1, y1, x2, y2):
    dx = x2 - x1
    dy = y2 - y1
    dist = math.sqrt((dx*dx)+(dy*dy))
    print dist

def calcPointRiwi(x1,y1,x2,y2):
    dx = x2-x1
    dy = y2-y1
    result = math.atan(dy / dx)
    result = (result * 400)/ math.pi          # Umrechnung in GON

    ## ACHTUNG SONDERBEHANDLUNGEN
    if(dy > 0 and dx > 0):result = result + 0
    if(dy > 0 and dx < 0):result = result + 200
    if(dy < 0 and dx < 0):result = result + 200
    if(dy < 0 and dx > 0):result = result + 400

    print "Hinweis:\n die Berechnung ist noch nicht ganz sauber."
    print result

def calcFreqLevelDist(freqInMHz, levelInDb):
    # dieses Skript soll auf Basis der Frequenz und dem WLAN-Level eine Strecke berechen.

    result = (27.55 - (20 * math.log10(freqInMHz)) + math.fabs(levelInDb)) / 20.0
    result = math.pow(10.0, result)     # Anwendung des 10er-Log
    result = result/ 3.28              # Umrechnung in Meter
    print result                        #Druckausgabe

## MAIN ----------------------------------------------------

Log("START")

Log("STRECKEN")

calcPointDist(230.30 ,401.10 , 280.50 , 461.20 )
calcPointDist(230.30 ,401.10 , 252.44 , 351.00 )
calcPointDist(230.30 ,401.10 , 186.36 , 350.50 )
calcPointDist(230.30 ,401.10 , 200.00 , 444.00 )
# -- funktioniert

Log("RIWI")

calcPointRiwi(401.10 , 230.30 , 461.20 , 280.50 )
calcPointRiwi(401.10 , 230.30 , 351.00 , 252.44 )
calcPointRiwi(401.10 , 230.30 , 350.50 , 186.36 )
calcPointRiwi(401.10 , 230.30 , 444.00 , 200.00  )

Log("ENDE")

## ----------------------------------------------
## Testumgebung

<file_sep>import os
import time

def ping(host):
    bOnline = False
    result = os.popen("ping -n 2 " + host).read()
    if result.find("ms") > -1:
        bOnline = True
        #print ("\t{} >>> SUCCESS".format(host))
    else:
        bOnline = False
        #print ("\t{} >>> FAIL".format(host))
    return bOnline

def ping2(hostname):
    response = os.system("ping -n 5 " + hostname)
    print 'ANTWORT ------------\n'
    print response
    if response == 0:
        pingstatus = "Network Active"
        #print hostname + ' ' + pingstatus
        return  pingstatus
    else:
        pingstatus = "Network Error"
        #print hostname + ' ' + pingstatus
        return pingstatus

# --- MAIN ----------------------------------------------------------
print time.ctime() + ' --- START '

pingresults = []
pingresults.append("google.com > {}".format(ping("google.com")))
pingresults.append("portal.lecrobag.de > {}".format(ping("portal.lecrobag.de")))
pingresults.append("SG-HHW019 > {}".format(ping("SG-HHW019")))
pingresults.append("RaspBerryPi > {}".format(ping("172.30.28.151")))
pingresults.append("DEX02 > {}".format(ping("10.49.0.17")))
pingresults.append("DEX23 > {}".format(ping("192.168.251.17")))

print pingresults

str_html="<html><head><style>div.on {border: 1px solid;width: 10px ;height: 10px;background-color: lime;}div.off {border: 1px solid;width: 10px;height: 10px;background-color: red;}</style></head><body><table>"

for item in pingresults:

    if item.find('google')>-1:
        print 'in google'
        if item.find('True') > -1 :   str_html = str_html + '<tr><td><div>google.de</div></td><td><div class="on"></div></td></tr>'
        else:                           str_html = str_html + '<tr><td><div>google.de</div></td><td><div class="off"></div></td></tr>'
    if item.find('SG-HHW019') > -1:
        print 'in HHW019'
        if item.find('True') > -1:    str_html = str_html + '<tr><td><div>SG-HHW019.schiffl-group.net</div></td><td><div class="on"></div></td></tr>'
        else:                           str_html = str_html + '<tr><td><div>SG-HHW019.schiffl-group.net</div></td><td><div class="off"></div></td></tr>'
    if item.find('lecrobag.de') > -1:
        print 'in lecrobag'
        if item.find('True')> -1:     str_html = str_html + '<tr><td><div>portal.Lecrobag.de</div></td><td><div class="on"></div></td></tr>'
        else:                           str_html = str_html + '<tr><td><div>portal.Lecrobag.de</div></td><td><div class="off"></div></td></tr>'
    if item.find('RaspBerryPi') > -1:
        print 'in RaspBerryPi'
        if item.find('True') > -1:    str_html = str_html + '<tr><td><div>RaspBerryPi</div></td><td><div class="on"></div></td></tr>'
        else:                           str_html = str_html + '<tr><td><div>RaspBerryPi</div></td><td><div class="off"></div></td></tr>'
    if item.find('DEX02') > -1:
        print 'in DEX02'
        if item.find('True') > -1:
            str_html = str_html + '<tr><td><div>DEX02</div></td><td><div class="on"></div></td></tr>'
        else:
            str_html = str_html + '<tr><td><div>DEX02</div></td><td><div class="off"></div></td></tr>'
    if item.find('DEX23') > -1:
        print 'in DEX23'
        if item.find('True') > -1:
            str_html = str_html + '<tr><td><div>DEX23</div></td><td><div class="on"></div></td></tr>'
        else:
            str_html = str_html + '<tr><td><div>DEX23</div></td><td><div class="off"></div></td></tr>'

str_html = str_html + '</table><br><div> Generiert am: {}'.format(time.ctime())
str_html = str_html + '	</body></html>'

print str_html

# open file for writing

fopen = open('C:/Users/langfeldn/Desktop/test.html','w')
fopen.write(str_html)
fopen.close()

os.startfile('C:/Users/langfeldn/Desktop/test.html')
print time.ctime() + ' --- ENDE '

<file_sep>## IMPORT
import time
import os

## START
print time.ctime() + " --- START --- "

path = 'V:\LECROBAG\ABLAGE\SHOPS\LE CROBAG POZNAN [618]'
os.chdir(path)
curDir = os.getcwd();
fileList = os.listdir(curDir);

print " {} Dateien gefunden".format((len(fileList)))
searchStr01 = 'Created new vouche id:'
outFile = "out.txt"
fopenOut = open(outFile,'w')

for file in fileList:
    fopen = open(file,'r')                  # ?ffenen
    data = fopen.readlines()                # auslesen
    fopen.close()                           # schlie?en
    #print "Dokument ge?ffnet: {}".format(file)
    #print "{} Zeilen gelesen".format(len(data))
    c = 0

    for line in data:
        if line.find(searchStr01) > 0:
            c = c + 1
            fopenOut.write(line)
            fopenOut.write(data[c])
            fopenOut.write(data[c+1])
            fopenOut.write(data[c+2])

    #print "{} Treffer".format(c)
    print "Dokument: {} |  Zeilen: {}  |  Treffer {}".format(file,len(data),c)

fopenOut.close()
## START
print time.ctime() + " --- ENDE --- "

## NOTIZEN ---------------------------------------------------------------------------------
# NEW_SALES_DATA = 4008
# Created new vouche = 4282

<file_sep>#
# IMPORT -----------------------
import time
import os

# METHODEN ---------------------
def LOG(text):  print "{} --- {}".format(time.ctime(), text)

# VARIABLEN --------------------

cwd = ''
fParent = ''
fChildren = []
fChild = ''
file2move = ''

# MAIN -------------------------

LOG('START')

# 1) Ordner wechseln

cwd = os.getcwd()
fParent = 'C:\Users\langfeldn\Documents\STEVEN'
os.chdir(fParent)
if os.getcwd() == fParent: LOG('Verzeichniswechsel erfolgreich')

# 2) fChildren ermitteln und fuellen

files = []
files = os.listdir(fParent)
for entry in files :
    dataTyp = entry[len(entry) - 4:len(entry)]
    if dataTyp.find('.') < 0 : fChildren.append(fParent + '\\' + entry)

# 3) in den Ordner rein, Datei suchen und verschieben
for i in fChildren:
    fChild = i
    os.chdir(fChild)
    fList = os.listdir(os.getcwd())
    if len(fList) > 0:
        file2move = fList[0]
        src = fChild + '\\' + file2move
        dst = fParent + '\\' + file2move
        print 'src: ' + src
        print 'dst: ' + dst
        os.rename(src, dst)
    else:
        file2move = '<no File>'

    #print "{} \n\t {}".format(fChild,file2move)

# 4) Ordner Ordner loeschen
# wurde vorerst manuell erledigt

LOG('ENDE')<file_sep># SplitMsg.py
# Dieses Skript soll einen InputString aufspliten und darstellen, das spart 2 Minuten

## BEISPIEL:

#  Bitte Text eingeben:
#  lCodeSection#= 2000, tmp_sAnlageUser#= SauerW, tmp_dAnlageDatum#= 20161101 00:00:00.000, tmp_lPersonalID#= 69377, tmp_lDatengruppe#= -21157, tmp_lVkeID#= 718, tmp_dBezugsdatum#= 20161101 00:00:00.000, tmp_dDatumAnfang#= 20161101 06:00:00.000, tmp_dDatumEnde#= 20161101 14:00:00.000, tmp_lArbeitszeitTypID#= 1, tmp_fAbzurechnendeStd#= 0, tmp_lStatus#= 1, tmp_lPausentaste#= 0, tmp_lGeloescht#= 0, tmp_lAbgeschlossen#= 0, tmp_fNachtzuschlag#= ,25, tmp_sBemerkungen#= NULL, tmp_dAktualisierungsdatum#= 20161201 18:45:11.045, tmp_sUserTmp#= SAUERW

#  /*
#  lCodeSection#= 2000
#  tmp_sAnlageUser#= SauerW
#  tmp_dAnlageDatum#= 20161101 00:00:00.000
#  tmp_lPersonalID#= 69377
#  tmp_lDatengruppe#= -21157
#  tmp_lVkeID#= 718
#  tmp_dBezugsdatum#= 20161101 00:00:00.000
#  tmp_dDatumAnfang#= 20161101 06:00:00.000
#  tmp_dDatumEnde#= 20161101 14:00:00.000
#  tmp_lArbeitszeitTypID#= 1
#  tmp_fAbzurechnendeStd#= 0
#  tmp_lStatus#= 1
#  tmp_lPausentaste#= 0
#  tmp_lGeloescht#= 0
#  tmp_lAbgeschlossen#= 0
#  tmp_fNachtzuschlag#=
#  25
#  tmp_sBemerkungen#= NULL
#  tmp_dAktualisierungsdatum#= 20161201 18:45:11.045
#  tmp_sUserTmp#= SAUERW
#  */

input = raw_input('\n\nBitte Text eingeben: \n')

inputsplit = input.split(',')
print('\n')

print '/*'
for item in inputsplit:
    print item.lstrip()
print '*/'
<file_sep>import math;
from random import random

def calcDist(x1,y1,x2,y2):
    dx = x2 - x1
    dy = y2 - y1

    dist = math.sqrt(dx^2/dy^2)
    print "Distanz: {}".format(dist)
    return dist

dist1 = calcDist(1,2,3,4)
dist2 = calcDist(1,2,3,8)

if dist1 > dist2:
    print "dist1 ist laenger"
if dist1 < dist2:
    print "dist2 ist laenger"<file_sep>file = 'C:\Users\langfeldn\Documents\Meine empfangenen Dateien\prod.beleg.v-2017-06-01.log'

fopen = open(file,'r')
data = fopen.readlines()
fopen.close()

print data[1]
idx_start = data[1].find('[',1)
idx_ende = data[1].find(']',idx_start)
print "hier"
print data[1][idx_start:idx_ende+1]

<file_sep># diese Skript dient dem Ablauf, dass das Serverlog in JSON geparst wird und aus dem resultierenden Objekt
# Update-Statements generiert werden

# 1) Open file

import json
import os

file = 'C:\Users\langfeldn\Documents\Meine empfangenen Dateien\prod.beleg.v-2017-06-01.log'

fopen = open(file,'r')
data = fopen.readlines()
fopen.close()

os.chdir('C:\Users\langfeldn\Documents\Meine empfangenen Dateien')
print os.getcwd()

fopen = open('out_update.txt','w')

for i in data:
    #print data[1]
    idx_start = data[1].find('[',1)
    idx_ende = data[1].find(']',idx_start)
    #print "hier"
    #print data[1][idx_start:idx_ende+1]
    fcontent = data[1][idx_start:idx_ende+1]

#file = 'C:\Users\langfeldn\Desktop\jsontest.txt'
#fopen = open(file,'r')
#fcontent = fopen.read()
#fopen.close()

#jsonObj = json.loads( '[{	"menge": "0",	"gposid": "1393806561",	"lposid": "106",	"artid": "1224",	"preis": "0",	"lvkpreis": "31790" }, {"menge": "0",	"gposid": "1393806629",	"lposid": "140",	"artid": "1461",	"preis": "0",	"lvkpreis": "11170"}]')

    jsonObj = json.loads(fcontent)

    #print jsonObj

    for entry in jsonObj:

        #'wasser'.replace('.','')
        gposid = entry['gposid']
        menge = entry['menge']
        menge = menge.replace('.', '').replace(',','.')
        #str_Select = "SELECT GPOSID, SARTIKEL, {} as MENGE_NEW, menge as MENGE_OLD FROM LCBDATA.V_AB_SONST WHERE GPOSID = {} \n UNION ".format(menge, gposid)
        #str_Select = "SELECT GPOSID, LVKEID, SARTIKEL, {} as MENGE_NEW, menge as MENGE_OLD FROM LCBDATA.V_AB_SONST WHERE GPOSID = {} \n UNION ".format(menge, gposid)
        str_update = "UPDATE LCBDATA.AB_SONST SET menge = {}, DAKTUALISIERUNGSDATUM = SYSTIMESTAMP  WHERE GPOSID = {};\n ".format(menge, gposid)
        #print str_Select

        #fopen.write(str_Select)
        fopen.write(str_update)

fopen.close()

<file_sep>

## Einlesen der Files

import os
import time

path = raw_input("Working Directory:\n")
os.chdir(path)
if path == os.getcwd(): print "success"
    ### perfekt bis hier laeuft es

## Dateien ermitteln
allList = os.listdir(path)
fileList = []
voucherDict = {}
kasseIndex = 0;
for entry in allList:
    if entry.find("database") <> -1 :
        print entry
        fileList.append(entry)

for entry in fileList:
    fullPath = path + '\\' + entry
    print "\n"+fullPath

    # dict

    # init counter
    c1 = c2 = c3 = c4 = c5 = 0

    fopen = open(fullPath,'r')
    data = fopen.readlines()

    for item in data:
        item = item.rstrip()

        if item.find("INSERT OR REPLACE INTO FRESH_COUNTS_ALL") > -1 :

            spItem = item.split(")::sql_params::[")
            sp001 = spItem[1].split(",")
            voucherID = sp001[6]
            if not voucherDict.has_key( voucherID ):
                voucherDict[voucherID] = ['','',''];
            voucherDict[voucherID][ kasseIndex ] = 'X';
            #print voucherDict

    fopen.close()
    kasseIndex += 1
    print kasseIndex

for entry in voucherDict:
    print "{} \t  {}".format(entry,voucherDict[entry])

#"rpcmethod":"DO_FRESH_POST"

#   - Obtained SELL_SALES_VOUCHER:
#   - parsing message type: STORNO_SALE_VOUCHER
#   - parsing message type: DO_FRESH_POST
#   - parsing message type: DO_DWINDLING
#   - parsing message type: DO_FRESH_FRACTION_DWINDLING
<file_sep>##
# Der Mqtt-Message-Counter soll sich eine Mqtt-Datei holen und die unterschiedlichen Messages zählen

# Workflow:
#   - open file
#   - find Messages
#   - count different messages

# --------------------------------------------------------------------------------
#   - open file

def openfile():
    import time                                             ## IMPORT
    import os                                               ## IMPORT
    print time.ctime() + " --- START"                       ## START
        ## LIST ALL FILES CONTAINING IN THE CURFOLDER
    path = "C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANIKA\ANALYSE\\20160622_v248_Kartenzahlung"
    os.chdir(path)                                          ## GET DIR
    curDir = os.getcwd();                                   ## CHANGE DIR
    fileList = os.listdir(curDir);                          ## GET FILELIST
    print "\n{} Dateien gefunden".format((len(fileList)))   ## PRINT RESULT
    for item in fileList:                                   ## PRINT FILES
        print " " + item                                    ## PRINT FILES
    choice = raw_input("\nBitte eine Datei angeben.  ");    ## CHOOSE FILE
    finPath = path + "\\" + choice                          ## CREATE FINAL FILEPATH
    fopen = open(finPath, 'r')                              ## OPEN FILE
    data = fopen.readlines();                               ## READ LINES
    lines = len(data)                                       ## READ LINES
    print "Es wurden {} Zeilen eingelesen\n".format(lines); ## PRINT RESULT
    print time.ctime() + " --- ENDEs";                      ## ENDE

# --------------------------------------------------------------------------------

# suchstring :
#   - Obtained SELL_SALES_VOUCHER:
#   - parsing message type: STORNO_SALE_VOUCHER
#   - parsing message type: DO_FRESH_POST
#   - parsing message type: DO_DWINDLING
#   - parsing message type: DO_FRESH_FRACTION_DWINDLING

# --------------------------------------------------------------------------------

# --------------------------------------------------------------------------------<file_sep>

## Einlesen der Files

import os
import time

path = raw_input("Working Directory:\n")
os.chdir(path)
if path == os.getcwd(): print "success"
    ### perfekt bis hier laeuft es

## Dateien ermitteln
allList = os.listdir(path)
fileList = []
voucherDict = {}

for entry in allList:
    if entry.find("database") <> -1 :
        print entry
        fileList.append(entry)

for entry in fileList:
    fullPath = path + '\\' + entry
    print "\n"+fullPath

    # dict

    # init counter
    c1 = c2 = c3 = c4 = c5 = 0

    fopen = open(fullPath,'r')
    data = fopen.readlines()
    for item in data:
        item = item.rstrip()

        if item.find("INSERT OR REPLACE INTO FRESH_COUNTS_ALL") > -1 :

            spItem = item.split(")::sql_params::[")
            sp001 = spItem[1].split(",")
            voucherID = sp001[6]
            voucherDict[voucherID] = (0,0,0)
            #print voucherDict

            if item.find("SELL") > -1:
                c1 = c1 + 1
            if item.find("DWINDLING") > -1:
                c2 = c2 + 1
            if item.find("ADD") > -1:
                c3 = c3 + 1
            if item.find("SELL_STORNO") > -1:
                print item
                c4 = c4 + 1
            if item.find("ADD_STORNO") > -1:
                c5 = c5 + 1

    print "{} - {}".format("SELL", c1)
    print "{} - {}".format("DWINDLING", c2)
    print "{} - {}".format("ADD", c3)
    print "{} - {}".format("SELL_STORNO", c4)
    print "{} - {}".format("ADD_STORNO", c5)

    fopen.close()

for entry in voucherDict:
    print entry

#"rpcmethod":"DO_FRESH_POST"

#   - Obtained SELL_SALES_VOUCHER:
#   - parsing message type: STORNO_SALE_VOUCHER
#   - parsing message type: DO_FRESH_POST
#   - parsing message type: DO_DWINDLING
#   - parsing message type: DO_FRESH_FRACTION_DWINDLING
<file_sep># python_
Collection of python snippets
<file_sep>

i = 0+4+0+4+2+9+3+8+3+4+1
print "JORGE {}".format(i)
i = 0+4+0+4+2+9+3+8+5+3+3
print "HEIKO {}".format(i)
i = 0+4+0+4+2+9+3+8+3+3+5
print "MATZE {}".format(i)
i = 0+4+0+4+2+9+3+8+3+4+6
print "PAUL {}".format(i)
i = 0+4+0+4+2+9+3+8+3+8+1
print "NILS {}".format(i)
i = 0+4+0+4+2+9+3+8+3+6+9
print "MICHEL {}".format(i)
i = 0+4+0+4+2+9+3+8+5+0+1
print "VICTORIA {}".format(i)

print "And the Winnder is PAUL"

import time
def getTime():
    print time.ctime()

getTime()
<file_sep># coding=utf-8
# Dieses Skript soll die Berechnungen zusammenfassen, die für die Berechungen in einem Dreieck notwendig sind.
# Hauptaugenmerk liegt auf der Fläche
<file_sep>
import urllib2
import os
import time

def log(text):
    print "{} -- {}".format(time.ctime(), text)

def onlineScan(url,saveFile):
    log('OnlineScan')
    # bSave = True or False
    log('Open URL')
#    urlObj = urllib2.urlopen("https://bs.to/serie/Game-of-Thrones")
    urlObj = urllib2.urlopen(url)
    log('Read Src')
    data = urlObj.read()
    #print data
    if len(saveFile) > 1:
        log('Write src 2 file')
        file = saveFile
        fobj = open(file, 'w')
        fobj.write(data)
        fobj.close()
        return data
    else:
        print len(data)
        return data

def offlineScan(file):
    log('OfflineScan')
    fobj = open(file,'r')
    data = fobj.readlines()
    fobj.close()
    return data

log('START')

data = onlineScan('https://bs.to/serie/Game-of-Thrones/5/','src.txt')
data = offlineScan('src.txt')
treffer = []
for item in data:
    if item.find('AuroraVid') > -1:
        tmp = 'https://bs.to/'+item.rstrip().lstrip().split('"')[5]
        treffer.append(tmp)
        print tmp

strTreffer = "{} Treffer".format(len(treffer))
log(strTreffer)

intLinks = treffer
extLinks = []

fObj = open('finalLinks.txt','w')

log('next step scan AuroraVid')
for intLink in treffer:
    log(intLink)
    urlObj = urllib2.urlopen(intLink)
    dataTmp = urlObj.read()
    urlObj.close()
    tmpFObj = open('scantmp.txt','w')
    tmpFObj.write(dataTmp)
    tmpFObj.close()
    tmpFObj = open('scantmp.txt','r')
    dataTmp = tmpFObj.readlines()
    tmpFObj.close()

    for item in dataTmp:
        #print item
        if item.find('//bs.to/out/') > -1:
            #print item
            extLink = item.split('"')[1]
            extLinks.append(extLink)
            #tmpstr = "{}\t>>>\t{}".format(extLink,intLink)
            #tmpstr = "{}".format(extLink)
            tmpstr = "{}".format(intLink)
            fObj.writelines(tmpstr+'\n')
            log(extLink)

#print dataTmp
fObj.close()

log('ENDE')

<file_sep>### ------------------------------------------------------------------------
##      SCAN4NPE.PY
##      - mit diesem Skript soll eine Reihe von Dateien gescannt werde
##      - Es soll ermittelt werden, ob und wann eine NPE aufgetreten ist
##      - Zusaetzlich soll f?r das Logfile der Shop und die jeweilige Kasse ermittelt werden
### ------------------------------------------------------------------------

## IMPORT
import time
import os

## METHODEN

def findHIT(in_str):
    searchStr01 = 'Created new vouche id'
    searchStr02 = "NEW_SALES_DATA"
    searchStr03 = "FreshInputFragment requested VoucheId"
    searchStr04 = "Stub::IAccountingRPC:doDwindling:"
    searchStr05 = "doInPaymentWithCurrencies"
    searchStr06 = "doOutPaymentWithCurrencies"
    searchStr07 = "doClosePaymentWithCurrencies"
    searchStr08 = "BillingBillFragment requested VoucheId:"
    searchStr09 = "ConfirmDialog requested VoucheId:"

    if in_str.find(searchStr01) > 0:
        print(in_str)
    if in_str.find(searchStr02) > 0:
        print(in_str)
    if in_str.find(searchStr03) > 0:
        print(in_str)
    if in_str.find(searchStr04) > 0:
        print(in_str)
    if in_str.find(searchStr05) > 0:
        print(in_str)
    if in_str.find(searchStr06) > 0:
        print(in_str)
    if in_str.find(searchStr07) > 0:
        print(in_str)
    if in_str.find(searchStr08) > 0:
        print(in_str)
    if in_str.find(searchStr09) > 0:
        print(in_str)

## START -------------------------------------------------------------------------------------------------
print time.ctime() + " --- START"

## LIST ALL FILES CONTAINING IN THE CURFOLDER
path = raw_input('Bitte Ordner angeben!\n')

os.chdir(path)
curDir = os.getcwd();
fileList = os.listdir(curDir);

print "\n{} Dateien gefunden".format((len(fileList)))
# ---------------------------------------------------------------------------------------------------------

for item in fileList:
    print " " + item
    finPath = path+"\\"+item
    fopen = open(finPath ,'r')
    data = fopen.readlines();
    lineCount = len(data)
    fopen.close()
    print "VERARBEITUNG >> "

    for line in data:
        findHIT(line.rstrip())

    print "Es wurden {} Zeilen verarbeitet\n".format(lineCount);

    print time.ctime() + " --- ENDE "

<file_sep>## Berechnung der Strecke zwischen zwei Punkten

# Punkt 1
x1 = 0
y1 = 0

# Punkt 1
x2 = -2
y2 = -2

## Calc
# calc deltas
dy = y2 - y1
dx = x2 - x1

s = abs(dy/dx)

print "Punkt 1 : [ {} | {} ] ".format(x1,y1)
print "Punkt 2 : [ {} | {} ] ".format(x2,y2)
print "DeltaX  : {} ".format(dx)
print "DeltaY  : {} ".format(dy)
print "Strecke : {} ".format(s)

## Quadrantenlogik
#
# | dx | dy | Quad
# | +  | +  | 1
# | +  | -  | 2
# | -  | -  | 3
# | -  | +  | 4

# wenn dx > 0 und dy > 0
<file_sep>
import sqlite3
import sys
import time
import os

# print time.ctime() + "--- import sqlite3 - success"
# print time.ctime() + "--- import sys - success"
# print time.ctime() + "--- import time - success"

def switchWS(wd):           # <<< PLEASE INSERT WORKINGDIRECTORY HERE
    os.chdir(wd)
    cwd = os.getcwd()
    dirList = os.listdir(cwd)
    fileList = []
    for f in dirList:
        if f.find('.db') > 0: fileList.append(cwd + '\\' + f)
    return fileList

def processDB(inFile):
    con = None
    sel = "SELECT count(*) , Reason  FROM FRESH_COUNTS group by REASON;"            ## FILL IN A SELECT IF NECESSARY
    try:
        con = sqlite3.connect(inFile)
        cur = con.cursor()
        cur.execute(sel)
        data = cur.fetchall()
    except sqlite3.Error, e:
        print "Error %s:" % e.args[0]
        sys.exit(1)
        data = []
    finally:
        if con: con.close()
        return data

## In weiser Vorraussicht, dass man vllt. auch mal Suedsteg analysieren
## muss, sollte man vllt. mal 7 dataStorages anlegen

data01 = []
data02 = []
data03 = []
data04 = []
data05 = []
data06 = []
data07 = []
c = 0                                                               # COUNTER
wd = 'C:\Users\langfeldn\Desktop\TEMP\\20161121_BremenTunnel'       # GRUNDLEGENDER ARBEITSBEREICH

fileList = switchWS(wd)

try:
    c = c + 1
    data01 = processDB(fileList[0])
    c = c + 1
    data02 = processDB(fileList[1])
    c = c + 1
    data03 = processDB(fileList[2])
    c = c + 1
    data04 = processDB(fileList[3])
    c = c + 1
    data05 = processDB(fileList[4])
    c = c + 1
    data06 = processDB(fileList[5])
    c = c + 1
    data07 = processDB(fileList[6])
except: print "Es wurden {} Datensaetze angelegt".format(c)
<file_sep>## Ermittlung aller *.db-Dateien im Ordner auf der angegebenen Ebene

## IMPORT -------------------------

import time
import os

## METHODE ------------------------

def log(text):
    print time.ctime() + ' --- ' + text

wd = 'C:\Users\langfeldn\Desktop\TEMP\\20161121_BremenTunnel'

os.chdir(wd)
log("CHDIR")

cwd = os.getcwd()
print " cwd = " + cwd

if cwd == wd : log("success")

dirList = os.listdir(cwd)
fileList = []

for f in dirList :
    if f.find('.db') > 0 : fileList.append(cwd + '\\' + f)

<file_sep>## ----------------------------------------------------------------
##  Analyse von Kassenlogfiles
##
## ----------------------------------------------------------------

## IMPORT ---------------------------------------------

import os
import time

## METHODE --------------------------------------------

def scanFile(infile, bool_print, 'out.txt'):
    fopen = open(infile, 'r')

    data = fopen.readlines();
    outStr = ''
    searchStr = "Created new vouche id"

    for line in data:
        if line.find(searchStr)>0:
            outStr = line
            res = outStr.split(':')
            if bool_print == True:
                print res[0] + ':' + res[1] + ':'+ res[2]+' ,' + res[5].rstrip('\n')

    fopen.close()

# SCAN - TEMP-ORDNER
print(time.ctime() + ' - - - START - - - - - - - - - - - - - -')

os.chdir("C:\\Users\\langfeldn\\Desktop\\TEMP")
dirList = os.listdir("C:\\Users\\langfeldn\\Desktop\\TEMP")

c0 = 0;
for f in dirList:
    c0 = c0 + 1;

fout = open('out.txt','w')

print(str(c0) + " Dateien gefunden.")

c1 = 0
for f in dirList:
    scanFile(f, False)
    c1 = c1 + 1
    print ("Datei " + str(c1) + " von " + str(c0))
    fout.append(

fout.close();
print(time.ctime() + ' - - - ENDE - - - - - - - - - - - - - -')

<file_sep>
## Dieses Script soll alle Dateien in einem Ordner scannen und auflisten

import os
import time

def log(text):
    import time
    print(time.ctime() + ' --- ' + text)

def changeDir():
    print ('Aktuelles Verzeichnis:\t\t\t' + os.getcwd())
    s_input = raw_input('Bitte Verzeichnis angeben:\t\t')
    os.chdir(s_input)
    print ('Aktuelles Verzeichnis:\t\t\t' + os.getcwd())
    return s_input

path = changeDir()
list_File = os.listdir(path)
ergStr = []

for item in list_File:
    #print item
    fpath = path + "\\" + item
    fopen = open(fpath,'r')
    data = fopen.readlines()
    fopen.close()

    for line in data:
        if line.find('setAktiveModul( 249,') > 0:
            line = line.rstrip()
            line = line.replace('T',' ')
            line = line.replace(',', '')
            split_ = line.split(' ')
            #print  split_
            ergStr.append(( split_[0], split_[1], split_[12], split_[13], split_[14], split_[15]))
            #print split_[0], split_[1], split_[12], split_[13], split_[14], split_[15]
            # print findata

ergStr.sort();

## Schreiben des Ergebnisses
outfile = path + "\\" + "out.txt"
fobj = open(outfile, 'w')

for item in ergStr:
    # print item
    fobj.write(item[0] + ',' + item[1] + ',' + item[2] + ',' + item[3] + ',' + item[4] + ',' + item[5]+ '\n')

fobj.close()

<file_sep># LOOP BASICS -----------------------
'''
for i in [2,4,6,8,10]:
    print "i = " , i

for i in range(10):
    print "i = " , i
'''
# LOOP BASICS -----------------------

# BOOL BASICS -----------------------
# i = 2
# print i % 2 == 0    # >> TRUE
# BOOL BASICS -----------------------

# Loop through the list from 1 to 21

# for i in range(1, 21):
#    if (i % 2) != 0:
#        print "i = ", i

# your_float = raw_input("Enter a float: \n")

# if your_float.find(",") > 0:
#    new_float = your_float.replace(",",".")
#    print "Deine Eingabe '{}' wird in '{}' geaendert".format(your_float,new_float)
#    your_float = new_float

# your_float = float(your_float)
# print ("Round to 2 decimals : {:.2f}".format(your_float))

## >> BUILDING A METHODE FOR REUSING
from operator import inv

def inputCatchKoma(prompt):
    your_float = raw_input(prompt + ": ")
    if your_float.find(",") > 0:
        new_float = your_float.replace(",",".")
        print "Deine Eingabe '{}' wird in '{}' geaendert".format(your_float,new_float)
        your_float = new_float
    return your_float

# TASK 001 ---------------------------------------
# Have the user enter their investment amount and expected interest
# each year their investment will increase by their
#  investment + investment * interess rate is
# Print out the earnings after a 10 year period

# Ask for the money invested + the interest rate
invest = inputCatchKoma("How much invest")
rate = inputCatchKoma("Interest rate")

# convert the values to float
invest = float(str(invest))

# round the percantage rate by 2 digits
rate = float(str(rate)) * .01

# cycle through 10 years using a for loop from 0 to 9
for i in range(10):
    invest = invest + (invest * rate)

# output results
print "Investment after 10 years = {:.2f}".format(invest)

<file_sep>
## IMPORT ------------------------------
import time
import os

def LOG(text):
    print time.ctime() + " --- " + text

## START
LOG("START")
## LIST ALL FILES CONTAINING IN THE CURFOLDER
path = "C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANALYSE"
f_path = "C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANALYSE\\File1.txt"
os.chdir(path)
curDir = os.getcwd();
## OPEN FILE
fopen = open(f_path ,'r')
## READ LINES
data = fopen.readlines();
lines = len(data)
## PRINT RESULT
print "Es wurden {} Zeilen eingelesen\n".format(lines);
## CLOSE FILE
fopen.close()

for entry in data:
    entry = entry.rstrip()
    split01 = entry.split(' ')
    print split01[0] + ' - ' + split01[13]

## c = 0;
## for entry in split01:
##     c = c + 1
##     print c.__str__() + ' - ' + entry

## ENDE
LOG("ENDE")<file_sep>### ------------------------------------------------------------------------
##      SCAN4NPE.PY
##      - mit diesem Skript soll eine Reihe von Dateien gescannt werde
##      - Es soll ermittelt werden, ob und wann eine NPE aufgetreten ist
##      - Zusaetzlich soll f?r das Logfile der Shop und die jeweilige Kasse ermittelt werden
### ------------------------------------------------------------------------

## IMPORT
import time
import os

## METHODEN

def findAppStart(in_str):
    searchStr01 = 'NullPointerException'
    searchStr02 = "Starting"

    #if in_str.find(searchStr01) > 0:
        #print(in_str)
        #return in_str
    if in_str.find(searchStr02) > 0:
        #print(in_str)
        return in_str

def genPrevString(input):
    strSplit = input.split(' ')
    strDate00 = strSplit[0]
    dateSplit = strDate00.split('.')
    strDate01 = dateSplit[2] + dateSplit[1] + dateSplit[0] + ' ' + strSplit[1]
    strOut = strDate01 + ' ' + input
    return strOut

## START -------------------------------------------------------------------------------------------------
print time.ctime() + " --- START"

## LIST ALL FILES CONTAINING IN THE CURFOLDER
#path = "C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANIKA\ANALYSE\\20160622_v248_Kartenzahlung"
#path = 'C:\Users\langfeldn\Desktop\WORK\PROJEKTE\LCB\ANIKA\ANALYSE\\20160715 - B-Hbf-Kartenzahlung\ANALYSE'
path = raw_input('Bitte Ordner angeben:\t\t\t')

os.chdir(path)
curDir = os.getcwd();
fileList = os.listdir(curDir);

print "\n{} Dateien gefunden".format((len(fileList)))
# ---------------------------------------------------------------------------------------------------------

output = []
for item in fileList:

    finPath = path+"\\"+item
    fopen = open(finPath ,'r')
    data = fopen.readlines();
    lineCount = len(data)
    fopen.close()

    for line in data:
        if findAppStart(line.rstrip()) is not None:
            dat00 = findAppStart(line.rstrip())
            dat01 = genPrevString(dat00)
            output.append(dat01)

output.sort();

for element in output:
    if element is not None:
        print element

print time.ctime() + " --- ENDE "

<file_sep>import time
import os

file = 'C:\Users\langfeldn\Desktop\TEMP\Berlin Hbf\input.txt'

fobj = open (file , 'r');
data = fobj.readlines()
fobj.close()

for item in data:
    if item.find('AMOUNT') > -1:
        data01 = item.split('[')
        data02 = data01[3].split(']')
        data03 = "{} \t {}".format(data02[0].split(',')[0], data02[0].split(',')[1])
        print data03<file_sep># Lesen
# Auswerten

# FileToRead = f2r

import time

#['16:42:01.603', '[qtp251210093-76005]', 'TRACE', 'AndroidServer.base', '-', 'Verkauf', 'v3:', 'Inside', 'SaleRPCRequestHandler::process', 'Method:getSalesVoucherSinceWithCurrenciesV3', 'Params:Class:class', 'com.schiffl.androidcash.common.anikabeans.CashIdentBean', 'toString:618:4', ',', 'Class:class', 'java.lang.Long', 'toString:1923839753', ',', 'Class:class', 'com.schiffl.androidcash.common.anikabeans.TimeStampBean', 'toString:2016.11.10', '12:00:00', ',', '\n']
#['16:42:13.228', '[qtp251210093-76236]', 'TRACE', 'DataLayer_Oracle-104', '-', 'ORACLE-DB:', 'Inside', 'DataLayer_Oracle::setAktiveModul(', '104,', '2,', 'Haupmenu)\n']

def hit01(input):
    string.split()

# START
print time.ctime() + " - START"

f2r = "C:\Users\langfeldn\PycharmProjects\ServerScripts\data\\20161111_001\\2016_11_11.stdout.log";
c = 0;      # COUNTER

fopen = open(f2r, 'r');
data = fopen.readlines();
fopen.close()

# Alle Daten lesen
for item in data:
    c = c + 1;
print "{} Zeilen gelesen".format(c);

# Einfuehrung von Suchstrings
searchStr01 = ' Method:getSalesVoucherSince';
searchStr02 = 'ORACLE-DB: Inside DataLayer_Oracle::setAktiveModul(';

# Processing
for item in data:
    item.rstrip();

    if item.find(searchStr01) > 0:
        #print item
        dat1 = item.split(' ');
        shop = dat1[12].split(':')[1]
        knr = dat1[12].split(':')[2]
        print "OR: {} {}/{}".format(dat1[0], shop, knr)

    if item.find(searchStr02)>0:
        if item.find('Haupmenu') > 0:
            dat2 = item.split(' ')
            print "HM: {} {}/{}".format(dat2[0], dat2[8].split(',')[0], dat2[9].split(',')[0])

#print dat1[0]

# funzt ... Augabe bei Hauptmenue funzt
#print "{} {}/{}".format(dat2[0], dat2[8].split(',')[0], dat2[9].split(',')[0])

# ENDE
print time.ctime() + " - FINISH"<file_sep># Dieses Skript empfängt einen Input und cleant diesen.
# Ziel ist es, dass alle auskommentierten Zeilen raus fliegen und nur noch
# der ProduktivCode übrig bleibt

languages: Markdown Python

repo_language: Markdown