TEXT2CSV

Converts AutoCAD table comprised by texts and lines into a CSV file.

CSV file can be opened in MS Excel, and then save as an XLS file.

INTRODUCTION

Command: TEXT2CSV
Select texts and lines:

Only text and line objects are valid for conversion. Please explode Polylines and Mtexts to lines and texts before conversion.
If no text in the selection, it prompts: No text selected.
Otherwise it converts them into a csv file and prompts:

CSV file has been created successfully:
......
[file path + file name]

The CSV file is saved in the same directory of the current dwg file with the same file name but with .csv extension.

You can also set a default directory to save all new csv files. You need save the directory name in a txt file named "TEXT2CSVPATH.txt" and save the txt file in one of AutoCAD search directories such as "C:\Users\[Your Windows loginname]\Documents" ("My Documents" directory in Windows).

For example, if you want to save all new csv files to a directory named "D:\My CSV Files\", you can save "D:\My CSV Files\" as the first line of "TEXT2CSVPATH.txt" and save the txt file to Windows "My Documents" directory.

If default csv file exists, it prompts:

Existing file: xxxx(file directory and filename), [Append/Overwrite/New] <Append>:

    • Append
      New data will be appended to the end of existing csv file

    • Overwrite
      Existing csv file will be replaced by the new data

    • New
      A "Select/Create a csv file" dialogue will pop-up to select an existing file or create a new file to save the data

Command: BREAKTEXT

It breaks up a text into small pieces by more than 1 continuous space characters.

For example, it breaks up one piece of text "The quick brown fox" into 4 text objects of "The", "quick" "brown" and "fox".

All small pieces of text stay at their original location.

This function is useful when your table row is made up of long rows of text separated by space characters. In this case you need use BREAKTEXT to create individual text objects first so that TEXT2CSV can identify columns.

TIPS

    • Instead of current drawing directory, you can also set a default directory to save all csv files.

    • It comprise a command BREAKTEXT to help break up a long text into small pieces.

NOTES

    1. Only text and line objects are valid, explode polyline and mtext objects before conversion.

    2. Lines take priority of texts to define the table cells. If there is no line object selected, the table cells are defined by the texts.

    3. Text position is based on their insert points in defining table columns, the visual position of text is used to define table rows. You may need use command TJUST to justify all texts and ensure their insert points are located in correct cells.

    4. Overlapped or very closed lines are deemed as a single line

    5. Bias lines to a certain extent (1/1000 horizontally and 1000/1 vertically) are deemed as valid lines to define the cells, lines out of this range are invalid - contact us if you want to increase the tolerance.

    6. A table cell contains of more than one rows of texts will be converted to a csv cell contains of multilines of texts.

    7. Overlapped texts or separated texts in the same row in the same cell are deemed as one row in the csv file, with three spaces to separate each text

    8. Texts outside the boundary defined by lines is saved as one colum or one row regardless how many rows or columns they are.

    9. If opened in Excel, the content of the csv table cells may not shown fully until the "text control" option of the spreadsheet is ticked as "Wrap text"

    10. If the new csv file is opened in Excel, and you convert the same dwg file to replace the old file, the csv file may become "read-only" until AutoCAD closed.

    11. The row and column of table are defined as same as current visual display, not current UCS.

    12. The lines selected to define the table cell are not necessarily to create perfect closed cells, TEXT2CSV can create cells logically from selected typical horizontal and vertical lines.

    13. Sometimes symbols in Unicode are converted into \U+XXXX format, you can use 'Find and Replace' function in Excel to replace them back to special symbols such as Ø.

EXAMPLES

The rules to use selected texts and lines to define rows and columns in a table are complicated, but just remember the following simplified basic rules:

1. If there is no lines in the selection, text coordinates are used to help define rows and/or columns.

2. Once there are lines in the selection to define rows and/or columns, text coordinates are only used to define the order within a cell if there are more than one text in a cell.

3. texts beyond the outmost lines are put into one row or one column.

1.1

A table of texts, without table lines.

All texts are justified to "Left".

The insert points of text in every column have the same X coordinate. Texts are placed in 6 rows loosely and the Y coordinates of text insert point in every row are different.

1.2

This is the conversion result of 1.1

If there is no table line to define the table cells, texts are sorted by their insertion points.

Texts with the same X coordinate are considered as in the same column, while texts with different Y coordinates may classified into the same row as long as they appear in a row. It allows texts moving up and down a fair bit in the same row.

The result in the csv file includes 6 rows and 6 columns.

2.1

Two horizontal lines are drawn in the table to define rows.

It accepts horizontal lines with a margin gradient which makes it not a strict "horizontal" line.

The horizontal line is not required to cover the full length of the table, so please ensure there is no short lines in the middle of a cell which are going to define few redundant rows.

A table line can contains more than one short segments, allowing gaps, overlapping and crossing, they can have different gradient as well, as long as they seem to form a table line. These wonderful features allow users convert scanned and vectorized table which sometimes doesn't has neat table lines.

2.2

This is the conversion result of 2.1

If there are horizontal lines in the selection, TEXT2CVS is going to use them to define rows in the table. In this case, the different Y coordinates of texts are only used to define rows within the same cell.

If there are no vertical lines in the selection, it still uses X coordinate of texts to define the columns.

Any texts above the top line or below the bottom line are considered as one row of cells. But within these top and bottom row of cells, it still can contain a few rows of texts, same as cells in the middle rows.

The result of the csv file contains 6 columns and 3 rows, and some cells contain 2 rows of text. You may need adjust the cell height and width in MS Excel to display full contents.


3.1

Two vertical lines are drawn in the table to define columns.

It accepts vertical lines with a margin gradient which makes it not a strict "vertical" line.

The vertical line is not required to cover the full height of the table, so please ensure there is no short lines in the middle of a cell which are going to define few redundant columns.

Same as horizontals line, a vertical line definition can contain a few line segments as well. As long as they look like forming a vertical line, they are considered as one line.

Any texts beyond the left line or the right line are considered as one column.

3.2

This is the conversion result of 3.1

If there are vertical lines in the selection, TEXT2CVS is going to use them to define columns in the table. In this case, the different Y coordinates of texts are only used to define rows within the same cell.

If there are no horizontal lines in the selection, it still uses texts' appearance to define the rows, ie. as long as them look like in a row, it put them in a row. It is not based on the Y coordinates of text insert point.

Within a cell, if there are more than 1 text and they have different X coordinates, it puts they in one string with space in between as the separator. The order of text in the string is depending on their X coordinates.

The result of the csv file contains 3 columns and 6 rows, and some cells contain a text string combined 2 texts with a space.

4.1

Two horizontal and two vertical lines are drawn in the table to define the rows and columns.

As mentioned in previous basic rules, in this case, if more than one texts are in a cell defined by lines, the Y coordinates of texts are only used to help define text rows in the cell and the X coordinates of texts are only used to define the text order in a combined text string.

4.2

This is the conversion result of 4.1

Apparently, the table is divided into 3 rows and 3 columns.

Some cells more than one rows of texts and some text row has two words separated by a space.

You can adjust the cell alignment in MS Excel to "Top" so the word "ant" can line up with word "bee" instead of "cow dog".

5.1

Three more short horizontal lines and two more vertical lines are added to define more rows and columns.

These lines are not necessarily to be full length and height if the table.

5.2

This is the conversion result of 5.1

The result of csv file contains 6 rows and 6 columns as we expected.

TRIAL RESTRICTION

  • In the trail version the conversion is limited to 2 rows only.

Please simply email liugesen@126.com to get a free Registration Code.

DISCUSSION

UPDATES

18 Jan 2020, Added command BREAKTEXT
22 Jan 2015, Allow user save new csv files to a predefined directory.
13 Apr 2013, Resolved an issue when 2 texts in 1 cell are selected.
01 Mar 2013, Resolved an issue when special characters such as , and " in the contents.
26 July 2011, If default csv file exists, it prompts "Existing file: xxxx(file directory and filename), [Append/Overwrite/New] <Append>:"
23 Sep 2010, First issue