You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.3 KiB

# importing pandas as pd
import os
from collections import defaultdict
import pandas as pd
import numpy as np
import openpyxl
import time
from pandas import Index
from docxtpl import DocxTemplate
from calendar import monthrange
import datetime
import calendar
import logging
import platform
plat = platform.system().lower()
if __name__ == '__main__':
payerId = '563347375094'
aws_feb = {}
read_file = "/server/billing/daimler/config/aws_feb.csv"
if plat == 'windows':
read_file = 'E:\\workspace_2\\施耐德\\daimler\\config\\aws_feb.csv'
total = 0
with open(read_file, 'r', encoding='utf-8') as r: # open(alterpath, 'w', encoding='utf-8') as w:
num = 0
while True:
line = r.readline()
if not line:
break
num += 1
data = line.split(',')
payer = data[0].replace(' ', '')
linkedAccountId = data[1].replace(' ', '')
if len(linkedAccountId) == 10:
linkedAccountId = "00" + linkedAccountId
elif len(linkedAccountId) == 9:
linkedAccountId = "000" + linkedAccountId
elif len(linkedAccountId) == 8:
linkedAccountId = "0000" + linkedAccountId
elif len(linkedAccountId) == 7:
linkedAccountId = "00000" + linkedAccountId
elif len(linkedAccountId) == 6:
linkedAccountId = "000000" + linkedAccountId
elif len(linkedAccountId) == 11:
linkedAccountId = "0" + linkedAccountId
unBlendedCost = data[2].replace('\n', '')
if not payer in payerId:
continue
aws_feb[linkedAccountId] = unBlendedCost
total += float(unBlendedCost)
aws_feb["total"] = total
print(aws_feb)
# if __name__ == '__main__':
# costs_maps = {}
# read_file = os.path.join('E:\\workspace_2\\施耐德\\costs\\', "563347375094.csv")
# linkaccountIds = []
# unBlendedCosts = []
# with open(read_file, 'r', encoding='utf-8') as r: # open(alterpath, 'w', encoding='utf-8') as w:
# num = 0
# while True:
# line = r.readline()
# if not line:
# break
# data = line[1:-2].split('","')
# num += 1
# if ('"关联账户' in data) or '关联账户' in data:
# linkaccountIds = data
# if ('"关联账户 总计' in data) or ('关联账户 总计' in data):
# unBlendedCosts = data
# person = []
# for index, i in enumerate(linkaccountIds):
# if i == '' or '关联账户' in i:
# continue
# costs_maps[i] = unBlendedCosts[index]
# if len(i)==11:
# line = ['0'+i, unBlendedCosts[index]]
# elif len(i)==10:
# line = ['00'+i, unBlendedCosts[index]]
# elif len(i) == 9:
# line = ['000' + i, unBlendedCosts[index]]
# elif len(i) == 8:
# line = ['0000' + i, unBlendedCosts[index]]
# elif len(i) == 7:
# line = ['00000' + i, unBlendedCosts[index]]
# elif len(i) == 6:
# line = ['000000' + i, unBlendedCosts[index]]
# person.append(line)