如何使用isql Firebird 3.04格式化csv文件中的输出?

piok6c0g  于 2023-04-03  发布在  其他
关注(0)|答案(2)|浏览(133)

我写了下面的脚本来从数据库中选择数据,并使用isql将其保存在csv文件中:

OUTPUT temp/filename.csv FORMAT csv DELIMITED BY ';';
SELECT dept_no, department, location FROM department;

我在csv文件中得到了以下结果:

DEPT_NO DEPARTMENT                LOCATION        
======= ========================= =============== 
000     Corporate Headquarters    Monterey        
100     Sales and Marketing       San Francisco   
600     Engineering               Monterey        
900     Finance                   Monterey        
180     Marketing                 San Francisco   
620     Software Products Div.    Monterey        
621     Software Development      Monterey        
622     Quality Assurance         Monterey        
623     Customer Support          Monterey        
670     Consumer Electronics Div. Burlington, VT  
671     Research and Development  Burlington, VT  
672     Customer Services         Burlington, VT  
130     Field Office: East Coast  Boston          
140     Field Office: Canada      Toronto         
110     Pacific Rim Headquarters  Kuaui           
115     Field Office: Japan       Tokyo           
116     Field Office: Singapore   Singapore       
120     European Headquarters     London          
121     Field Office: Switzerland Zurich          
123     Field Office: France      Cannes          

DEPT_NO DEPARTMENT                LOCATION        
======= ========================= =============== 
125     Field Office: Italy       Milan

然而,我需要得到一个输出1)没有重复的标题和2)没有列中数据之间的空间。
理想的输出应该是这样的:

ID;LASTNAME;FIRSTNAME;DOB
1;Miller;Steve;1980-06-28
2;Jones;Martha;1965-11-02
3;Waters;Richard;1979-10-15

有人能帮我解决这个问题吗?先谢谢你了😊

ou6hu8tu

ou6hu8tu1#

这会对你有所帮助。它使isql在每个

isql -pag 100000
5vf7fwbs

5vf7fwbs2#

您可以添加一个串联a ';'到select中的每个字段(当然最后一个除外),如select(fieldname)||';'作为xxxxx,(fieldname)||“;”作为xxxxx........
(标题仍然是一个字段)
1;米勒;Steve;1980-06-28 2;琼斯玛莎1965-11-02 3;沃茨;理查德;1979-10-15

相关问题