Why is only half my data being passed into my dictionary?

freezeboi

When I run this script I can verify that it loops through all of the values, but not all of them get passed into my dictionary

file = open('path', 'rb')
readFile = PyPDF2.PdfFileReader(file)

lineData = {}

totalPages = readFile.numPages

for i in range(totalPages):
    pageObj = readFile.getPage(i)
    pageText = pageObj.extractText
    newTrans = re.compile(r'Jan \d{2,}')
    for line in pageText(pageObj).split('\n'):
        if newTrans.match(line):
            newValue = re.split(r'Jan \d{2,}', line)
            newValueStr = ' '.join(newValue)
            newKey = newTrans.findall(line)
            newKeyStr = ' '.join(newKey)
            print(newKeyStr + newValueStr)
            lineData[newKeyStr] = newValueStr
print(len(lineData))

There are 80+ data pairs but when I run this the dict only gets 37

Pavel M.

Well, duplicate keys, maybe? Try to make lineData = [] and append there: lineData.append({newKeyStr:newValueStr} and then check how many records you get.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why are only two of my four methods being read in my code?

Why is my array only printing half my values

Why are my meteor settings not being passed to the application?

Why is Context not being passed to my HOC

Why is my variable not properly being passed in React Native?

Why are my hidden input not being passed in the model class?

Why are my props not being passed to my child component?

Why is my search function not being passed?

why is my XOR operation only implemented on half of my text file

Why is my array being passed with an incorrect size?

React.js Virgin: Why is my hard coded data being passed differently than data entered by user?

Why is Live Server only loading half my HTML code?

Why is my data not being displayed?

Why is my INT variable being passed by reference?? C#

Why is my loop in a loop only printing half the list length?

Why aren't my arguments being passed to the parameters?

Why aren't the values from my directive being passed into the function?

Why is my input not being passed into the if statements?

Why does my noUiSlider only respect the "step" value on half of the slider?

HTML canvas. Only half of my image is being flipped

Why isn't my prop logging or being passed in React Native?

Why is my app rendering only one half of the page?

How do I check why my internet is only half working?

Why isnt my data my being inseretd into my database

Why is nothing being passed to my overloaded function?

why my data passed by binding stay undefined?

Flutter: Why is my function passed to `StatelessWidget` not is not being executed?

Flutter: Why is my custom function passed to a `StatelessWidget` object not being executed?

Why is my dictionary not being changed outside of my function