Importing line-by-line from a text file
Al momento, stai seguendo questa domanda
- Vedrai gli aggiornamenti nel tuofeed del contenuto seguito.
- Potresti ricevere delle e-mail a seconda delle tuepreferenze per le comunicazioni.
Si è verificato un errore
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
0 voti
Condividi un link a questa domanda
1 Commento
Condividi un link a questo commento
Risposta accettata
0 voti
Condividi un link a questa risposta
- " how to tackle the spaces"   depends on how you want the spaces in the resulting string variable values
- "line-by-line"   what exactly do you mean?
- use Import Data interactively to read from a file of format B (one header line, comma separated, varying width) to a table. Make sure to uncheck Multiple Delimiters as One and select table. I've tested; it worked fine.
- spend time with the documentation of table instead of fighting file formats.
7 Commenti
Condividi un link a questo commento
Condividi un link a questo commento
- the entire file fits easily in memory
- each row is approx. 480 bytes
- the file has 120 columns
- It's not practical to write a format-specifier "manually"
- "text file had fixed with" are you sure? Inspection in editor show me that all columns don't have fixed width. I doubt that it is safe to rely on position.
- there are 134 names in the header line, but only 123 columns in the first two data rows. Why?
- all rows do not contain the same number of columns

Condividi un link a questo commento
Condividi un link a questo commento
- I found out a text file with fixed width's this time, I think its gonna be easy. But I have a doubt how do I compare a fixed width for example a state code is 356 and is placed at the start of each line. So for an if statement should I use eg: if(NBIdata(1:3)=='356')
- Also how do I write to direct the pointer from one line to another?
Condividi un link a questo commento





Condividi un link a questo commento
Condividi un link a questo commento
Più risposte (0)
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
