| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1989 人关注过本帖
标题:dbf如何转换成字段间有特定分隔符的txt文件
取消只看楼主 加入收藏
jjjlan
Rank: 1
等 级:新手上路
帖 子:67
专家分:0
注 册:2004-11-24
收藏
 问题点数:0 回复次数:0 
dbf如何转换成字段间有特定分隔符的txt文件

dbf如何转换成字段间有特定分隔符的txt文件

例:一个DBF表a,要求转换成TXT文件b,各字段间用"^"号分隔,程序应怎么写? COPY TO B.TXT DELIMITED WITH CHARACTER ^ ******************************************************************************************* COPY TO FileName [DATABASE DatabaseName [NAME LongTableName]] [FIELDS FieldList | FIELDS LIKE Skeleton | FIELDS EXCEPT Skeleton] [Scope] [FOR lExpression1] [WHILE lExpression2] [ [WITH] CDX ] | [ [WITH] PRODUCTION ] [NOOPTIMIZE] [ [TYPE] [ FOXPLUS | FOX2X | DIF | MOD | SDF | SYLK | WK1 | WKS | WR1 | WRK | CSV | XLS | XL5 | DELIMITED [ WITH Delimiter | WITH BLANK | WITH TAB | WITH CHARACTER Delimiter ] ] ] [AS nCodePage] Parameters FileName Specifies the name of the new file to create. If you do not include a file extension, COPY TO assigns the default extension for the specified file type. If you do not specify a file type, COPY TO creates a new Visual FoxPro table and assigns the default .dbf extension to the table file name. DATABASE DatabaseName Specifies a database to which the new table is added. NAME LongTableName Specifies a long name for the new table. Long names can contain up to 128 characters and can be used instead of short file names in the database. FIELDS FieldList Specifies which fields are copied to the new file. If you omit FIELDS FieldList, all fields are copied to the file. If the file you are creating is not a table, memo fields are not copied to the new file, even if memo field names are included in the field list. FIELDS LIKE Skeleton Specifies that fields from the original table that match the field skeleton Skeleton are included in the new file that COPY TO creates. FIELDS EXCEPT Skeleton Specifies that all fields except those that match the field skeleton Skeleton are included in the new file that COPY TO creates. Scope Specifies a range of records to copy to a file. Only the records within the range are copied. The scope clauses are: ALL, NEXT nRecords, RECORD nRecordNumber, and REST. For more information on scope clauses, see Scope Clauses. FOR lExpression1 Specifies that COPY TO copies only the records for which the logical condition lExpression1 evaluates to True (.T.) to the file. To conditionally copy records, include the FOR lExpression1 clause to filter out undesired records. WHILE lExpression2 Specifies a condition where records are copied while the logical expression lExpression2 evaluates to True (.T.). [WITH] CDX | [WITH] PRODUCTION Creates a structural index file for the new table that is identical to the structural index file of the existing table. The tags and index expressions from the original structural index file are copied to the new structural index file. The CDX and PRODUCTION clauses are identical. However, do not include CDX or PRODUCTION if you are copying to a file other than a new Visual FoxPro table. NOOPTIMIZE Disables Rushmore Query Optimization for COPY TO. For more information, see SET OPTIMIZE and Using Rushmore Query Optimization to Speed Data Access. TYPE Specifies the file type if the file you create is not a Visual FoxPro table. Although you must specify a file type, you do not need to include the TYPE keyword. FOXPLUS Visual FoxPro memo files have a different structure than Microsoft FoxBASE+™ memo files. If your source Visual FoxPro table contains a memo field, include the FOXPLUS clause to create a table that can be used in FoxBASE+. The Visual FoxPro memo field cannot contain binary data because FoxBASE+ does not support binary data in memo fields. FOX2X Creates a new table that can be opened in earlier versions of FoxPro (versions 2.0, 2.5, and 2.6). For Numeric, Float, Integer, Double, and Currency type fields, null values in the source table are converted to zero in the new table. For other field types, null values in the source table are converted to blanks in the new table. For further information about blank values, see ISBLANK( ).

The following table lists the Visual FoxPro field types that are converted to different field types in the new table when the FOX2X argument is included.

Visual FoxPro field type FoxPro 2.x field type Currency Float DateTime Date Double Float Integer Numeric

DIF Creates a VisiCalc® .dif (Data Interchange Format) file. Fields from the Visual FoxPro table become vectors (columns) and records become tuples (rows). The new file name is assigned a .dif extension if you do not include an extension in FileName. MOD Creates a Microsoft Multiplan® version 4.01 file. The new Microsoft Multiplan file name is assigned a .mod extension if an extension is not included. SDF Creates an SDF (System Data Format) file. An SDF file is an ASCII text file in which records have a fixed length and end with a carriage return and line feed. Fields are not delimited. The SDF file name is assigned a .txt file extension if you do not include an extension. The SET CENTURY setting is ignored when creating SDF files with COPY TO. If SDF files include date data, it should be in YYYYMMDD format to allow effective reconversion into Visual FoxPro tables.

If date information is stored in ambiguous formats, you should make sure that the dates are in YYYYMMDD format before you perform the COPY TO operation.

SYLK Creates a SYLK (Symbolic Link) interchange file. SYLK files are used in Microsoft MultiPlan. Each field from the currently selected table becomes a column in the spreadsheet, and each record becomes a row. SYLK file names have no extension. WK1 Creates a Lotus® 1-2-3® version 2.x spreadsheet file. Each field from the currently selected table becomes a column in the spreadsheet and each record becomes a row. A .wk1 file name extension is assigned to the new spreadsheet. WKS Creates a Lotus 1-2-3 version 1a spreadsheet file. Each field from the currently selected table becomes a column in the spreadsheet and each record becomes a row. A .wks file name extension is assigned to the new spreadsheet. WR1 Creates a Lotus Symphony® version 1.1 or 1.2 spreadsheet file. Each field from the currently selected table becomes a column in the spreadsheet and each record becomes a row. A .wr1 file name extension is assigned to the new spreadsheet. WRK Creates a Lotus Symphony version 1.0 spreadsheet file. Each field from the currently selected table becomes a column in the spreadsheet and each record becomes a row. A .wr1 file name extension is assigned to the new spreadsheet. CSV Creates a comma separated value file. A CSV file has the field names as the first line in the file, and the field values in the remainder of the file are separated with commas. XLS Creates a Microsoft Excel version 2.0 worksheet file. Each field from the currently selected table becomes a column in the spreadsheet, and each record becomes a row. If you do not include a file extension, an .xls extension is assigned to the new worksheet. Note Though you can export a maximum of 65,535 rows, which includes one row reserved for the field header, versions of Excel earlier than 8.0 (Excel 97) display only the first 16,384 rows and cannot import files containing more than 32,767 rows. XL5 Creates a Microsoft Excel version 5.0 workbook file. Each field from the currently selected table becomes a column in the spreadsheet, and each record becomes a row. If you do not include a file extension, an .xls extension is assigned to the new workbook. Note Though you can export a maximum of 65,535 rows, which includes one row reserved for the field header, versions of Excel earlier than 8.0 (Excel 97) display only the first 16,384 rows and cannot import files containing more than 32,767 rows. DELIMITED Creates a delimited file. A delimited file is an ASCII text file in which each record ends with a carriage return and line feed. The default field separator is a comma. Because character data can include commas, character fields are additionally delimited with double quotation marks. Unless you specify otherwise, a .txt extension is assigned to all newly created DELIMITED files.

DELIMITED WITH Delimiter Creates a delimited file with character fields delimited by a character other than a quotation mark. The character that delimits character fields is specified with Delimiter. DELIMITED WITH BLANK Creates a delimited file with fields separated by spaces instead of commas. DELIMITED WITH TAB Creates a delimited file with fields separated by tabs instead of commas. DELIMITED WITH CHARACTER Delimiter Creates a delimited file with all fields enclosed by the character specified with Delimiter. If Delimiter is a semicolon (;), used in Visual FoxPro to indicate command line continuation, enclose the semicolon in quotation marks. You can also specify the BLANK and TAB keywords for Delimiter. You can combine the WITH Delimiter clause with the WITH CHARACTER clause. For example, the following command creates a text file with character fields enclosed by underscores and all fields delimited from each other with semicolons:

COPY TO mytxt.txt DELIMITED WITH _ WITH CHARACTER ';' AS nCodePage Specifies the code page for the table or file that COPY TO creates. Visual FoxPro copies the contents of the currently selected table, and, as it copies the data, automatically converts the data to the code page you specify for the new table or file. If possible, Visual FoxPro marks the newly created table or file with the code page you specify. If you omit AS nCodePage, the newly created table or file is converted to the current Visual FoxPro code page.

搜索更多相关主题的帖子: dbf txt 字段 文件 分隔 
2005-06-18 08:54
快速回复:dbf如何转换成字段间有特定分隔符的txt文件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017239 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved