Digamos que tenemos una tabla con 3 columnas (ejemplo a continuación). Creo un subconjunto de tablas por la columna "código de ciudad" que incluirá las 3 columnas.
| Código de ciudad | Número de registro | Fecha de Registro |
| 032 | 0320537648 | 20201026 |
| 160 | 1600084082 | 20201020 |
| 281 | 2821162566 | 20201020 |
| 325 | 3250488500 | 20201024 |
| 420 | 4200618843 | 20201101 |
| 511 | 5110680174 | 20201027 |
| 720 | 7200054737 | 20200825 |
Me gustaría guardar solo los archivos de subconjunto como archivos de texto de la siguiente manera: código de ciudad value.txt
Encontré el siguiente script jsl en el foro que fue muy útil para guardar los archivos como archivos de texto. El problema es que los archivos se guardan como código de ciudad = valor.txt
La tabla de datos principal también se guarda en un archivo de texto, que no quiero.
//Save as txt file
openDTs = {};
For( i = 1, i <= N Table(), i++,
Insert Into( openDTs, Data Table( i ) )
);
For( i = 1, i <= N Items( openDTs ), i++,
one_name = openDTS[i] << get name;
file_path = one_name || ".txt";
openDTS[i] << Save(file_path);
);
Soy nuevo tanto en JMP como en scripting, por lo que cualquier idea es muy apreciada.
A continuación se muestra un script que creará la tabla de datos de ejemplo que proporcionó.Luego creará los subconjuntos y guardará cada subconjunto como un archivo .txt.
Todo lo que se necesita hacer para ejecutar este ejemplo es cambiar la línea de código
saveFolder = "C:\xxxxxxxxxxxxx\";
a cuál es la ruta real a la carpeta para guardar los archivos, y luego ejecute el código
Names Default To Here( 1 );
// Create the example data table
New Table( "Example",
Add Rows( 7 ),
New Column( "City code", Numeric, "Continuous", Format( "Best", 12 ), Set Selected, Set Values( [32, 160, 281, 325, 420, 511, 720] ) ),
New Column( "Registration Number",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [320537648, 1600084082, 2821162566, 3250488500, 4200618843, 5110680174, 7200054737] )
),
New Column( "Registration Date",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [20201026, 20201020, 20201020, 20201024, 20201101, 20201027, 20200825] )
)
);
// Here is the real code.....just change the saveFolder = to the actual folder you want to
// save the files to
dt = Current Data Table();
// Create the subsets
dtSub = dt << Subset( By( :City code ),
All rows, Selected columns only( 0 ),
columns( :Registration Number, :Registration Date ) );
saveFolder = "C:\xxxxxxxxxxxxx\";
For( i = 1, i <= N Items( dtSub ), i++,
// Given the structure of the data tables created with a Subset using a By() clause
// City Code = 32
// the Word() function retuns the "32" and it is added as the name of the file to save
dtSub[i] << Save( saveFolder || Word( -1, dtSub[i] << get name, "=" ) || ".txt" )
);