如何通过从命令行进行管道导入XML?
我正在使用XML2 |从XML转换为CSV。 2CSV
工具,然后调用.import
to sqlite。我不想生成一个CSV文件,而是想将转换的文件从XML2
传输到.import
QUERY。
我有tags.xml:
<tags>
<row Id="1" TagName=".net" Count="316293" ExcerptPostId="3624959" WikiPostId="3607476" />
<row Id="2" TagName="html" Count="1116853" ExcerptPostId="3673183" WikiPostId="3673182" />
<row Id="3" TagName="javascript" Count="2343663" ExcerptPostId="3624960" WikiPostId="3607052" />
</tags>
因此,而不是进行此转换:
xml2 | 2csv row @Id @TagName @Count @ExcerptPostId @WikiPostId < tags.xml > tags.csv
然后从命令行导入数据库:
sqlite3 mydb.db -csv ".import tags.csv tags"
我想要从命令行类似的东西:
sqlite3 mydb.db -csv ".import <xml2 | 2csv command> tags"
我的XML文件约为100GB,所以我不想实现它。
I'm converting from XML to CSV with xml2 | 2csv
tool, then call .import
to SQLite. I don't want to generate a CSV file, but want to pipe the converted file from xml2
to the .import
query.
I have tags.xml:
<tags>
<row Id="1" TagName=".net" Count="316293" ExcerptPostId="3624959" WikiPostId="3607476" />
<row Id="2" TagName="html" Count="1116853" ExcerptPostId="3673183" WikiPostId="3673182" />
<row Id="3" TagName="javascript" Count="2343663" ExcerptPostId="3624960" WikiPostId="3607052" />
</tags>
So instead of doing this conversion:
xml2 | 2csv row @Id @TagName @Count @ExcerptPostId @WikiPostId < tags.xml > tags.csv
Then importing to database from command line:
sqlite3 mydb.db -csv ".import tags.csv tags"
I want something like this from the command line:
sqlite3 mydb.db -csv ".import <xml2 | 2csv command> tags"
My XML file is around 100GB so I don't want to materialize it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对90 GB文件进行相同的操作,这是我的导入方式:
xml2
的转换是通过管道发生的,2CSV
的Stdout直接传递到STDIN中sqlite3
I do the same with a 90 GB file, here is how I import it:
The conversion with
xml2
happens via pipes, and the stdout of2csv
is passed directly into the stdin ofsqlite3