-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix to issue #94 #95
fix to issue #94 #95
Conversation
now all text will inferred as string and the user can change it to their desired data type.
_cols.remove('text') | ||
for col in _cols: | ||
_df[col] = _df[col].astype(int) | ||
res['data'] = _df |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try the following code:
_data = pytesseract.image_to_data(img_content, lang=self.lang, **self.configs)
df = pd.read_csv(
io.StringIO(_data), quoting=csv.QUOTE_NONE, encoding="utf-8", sep="\t"
)
df['text'] = df['text'].astype('str')
res["data"] = df
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lolipopshock sorry it does not, I have tried this
and ya i get it, the for loop and all that stuff looks ugly :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see -- it's the issue from floating point numbers .0
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
I think the new solution can solve your issue -- see example below: Let's say we have a csv file
And if we read it via:
We have
(There's no |
Fixes # #94 (comment)
#94
The issue was, all digit sequences were inferred as float, with this fix all text (numeric + non-numeric) will be inferred as string and the user can change it to their desired data type.
But with this fix, the user will be required to change the numeric data type columns.
i could not find any better solution other than this.