@emmablue, Jim provided a solution of how to fix the problem once the text file is imported. I will explain two options, each depends upon your original file.
#1 If your original file has spaces as the column delimiters, the fix could be easy. When you select File >Open use the option Data with Preview and make sure both Space and Spaces are selected
If you had selected Data, using Text Import Preferences, your default could be Space. If that is the case, the fix via the UI is use Data with Preview. If you are using a script, the Open statement in the script below should be used.
#2 If your original file has tabs as the column delimiters, the fix is not as easy. Via the UI you can use a text editor and use find an replace a tab with spaces. I found no method to specify Tabs in case there are extra tabs. Comment: a Tabs option might be a good wish list item, or allow the user to specify more than one character such as 0x090x09 or HexToChar("0909") for Other or add an option to Ignore repeated delimiters. If you cannot edit the file, or do not want to use the text editor to replace each tab with a space, and if you are using a Windows PC, you can modify the JSL file below by changing the file paths. If your Name column has spaces this will not work and a different script using regular expressions can be used to replace duplicate tabs with a single tab.
If you copy and pasted the data into the table, then you should use Jim's solution.
If you have more details about the input file, a more useful script/solution can be provided.
Names Default to Here(1);
findchar = "\!t"; //tab
infid = "C:\temp\ExtraTab_testIn.txt"; //file path
outfid = "c:\temp\_xxxdummy.txt";
//This was DOS script was found at StackOverflow 1/16/2019
//https://stackoverflow.com/questions/23075953/batch-script-to-find-and-replace-a-string-in-text-file-without-creating-an-extra/23076141
//It replaces the tabs in the infid with spaces and writes it to a outfid with spaces.
//If you want to replace the original file's tabs do the following
// uncomment lines 29 and 30 below: "del %textfile"" and "rename %newfile %textfile"
// change the Open( outfid, ..) to Open(infid, ...) in line 38
//To keep outfid, don't make the changes described above. But comment or delete the last JSL statement
dos_cmds = {
"cd c:\temp",
"@echo off &setlocal",
EvalInsert("set \!"search=%^findchar^\!""),
"set \!"replace=% \!"",
EvalInsert("set \!"textfile=^infid^\!""),
EvalInsert("set \!"newfile=^outfid^\!""),
"(for /f \!"delims=\!" %%i in (%textfile%) do (",
" set \!"line=%%i\!"",
" setlocal enabledelayedexpansion",
" set \!"line=!line:%search%=%replace%!\!"",
" echo(!line!",
" endlocal",
"))>\!"%newfile%\!""
// , "del %textfile%",
// "rename %newfile% %textfile%"
};
txt = concat items(EvalList(dos_cmds), "\!N");
f = Save Text File("c:\temp\Find_Replace.bat", txt, Mode("replace"));
Web("c:\temp\Find_Replace.bat"); //simple command to execute a .bat
dt = Open( outfid,
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Spaces, Space, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 0 ),
Column Names Start( 1 ),
Data Starts( 1 ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
);
If( File Exists(outfid), Delete File(outfid) );