使用C++或Python将一个表格PDF数据转换成文本(或任何其他可读格式)文件

2024-06-12 05:47:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个PDF文件,其中包含一所大学的时间表,由aSc时间表软件生成

数据看起来像这样

PDF文件中大约有29个这样的页面

我想处理这个程序的数据,因此,希望它在任何编程语言中都是可读的,最好是C++或Python语言。p>

谁能指导我怎么做?也许我可以使用一些库来将这些数据转换成一个文本文件,使用C++?p>

我需要的是这种形式的数据

假设在C++中,我们有一个类,名为<强>节< /St>(一个对象将表示每个部分,例如“BCS-1A”对象或“BCS-7E”对象等)

那么,对于BCS-1A

Section Object: 

section_name: "BCS-1A" // (section_name is a string data member)
// There will be 7 arrays, each representing one day of the week and each array will be of size 16. One index of the array will represent one time slot of that day. So, in this case, 

moday_schedule[16]; // it will be an **linked list** array of 16 size. Each index can be empty or may contain as many slots as possible. Each index represents the time slot in the timetable. For example "0th" index will represent the time slot of 8:45 to 9:15, 16th index will represent 4:15 to 4:40 and etc. 

// For example, monday_schedule[0] will be EMPTY.
// monday_schedule[4] will contain an object that will have following information,

// Subject: Digital Logic Design
// Teacher: Mirza Waqar Baig
// Sub-section: None (there is a sub-section in some lectures)
// Room: R-5

// monday_schedule[5] will also contain same information

// monday_schedule[12] will have two objects.
// and both the objects will have an attribute of "Sub-section" as well 

Tags: andofthe数据对象indextimesection
1条回答
网友
1楼 · 发布于 2024-06-12 05:47:15

我已经在GitHub上编译了一个repository

我使用pdf2image首先将pdf转换为图像文件,并将这些文件存储在图像文件夹中。
然后使用pytesseract将这些图像转换为txt文件,并将这些txt文件存储在text文件夹中。
之后,我对文本进行了一些格式化,并将其以csv格式存储在csvs文件夹中

相关问题 更多 >