我试图使用AWS的DetectDocument (异步)从PDF文件中提取表格和数据,使用的是C#/.NET。
我在数据提取方面很成功,但我不知道如何使用AnalyzeDocument提取PDF中的表格并导出到CSV文件中。
阅读亚马逊网络服务的文档,在Python中找到CSV解压缩,而不是在.NET中。请参阅链接:- https://docs.aws.amazon.com/textract/latest/dg/examples-export-table-csv.html
尝试查看Python代码并复制.NET,但没有成功。
发布于 2020-07-28 15:23:37
我们可以使用这段代码,遍历由textract的GetDocumentTextAnalysis()返回的块中的关系,并获得链接到它的所有子节点。
var relationships = block.Relationships;
if(relationships != null && relationships.Count > 0) {
relationships.ForEach(r => {
if(r.Type == "CHILD") {
r.Ids.ForEach(id => {
var cell = new Cell(blocks.Find(b => b.Id == id), blocks);
if(cell.RowIndex > ri) {
this.Rows.Add(row);
row = new Row();
ri = cell.RowIndex;
}
row.Cells.Add(cell);
});
if(row != null && row.Cells.Count > 0)
this.Rows.Add(row);
}
});
}
作为参考-请参阅底部代码的链接:-
https://stackoverflow.com/questions/57766767
复制相似问题