We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question
0

Total # lines in .txt file

asked 2021-04-26 00:16:15 +0200

Jeek gravatar image

updated 2021-06-28 23:52:41 +0200

Alex Kemp gravatar image

Is there a function ( macro ) that returns the number of lines in text file ?
Macro is in Libre draw.

If not, any eloquent recommendations to find total number lines in text file?

edit retag flag offensive close merge delete

Comments

Depending on which operating system you use, why not open the .txt document in Notepad++ or NotepadQQ, each of which will display line numbers and give you the total number of lines in the document.

ve3oat gravatar imageve3oat ( 2021-04-26 01:39:21 +0200 )edit

Yes, that would provide line numbers, but I would prefer not to have to manually input into macro in this case; rather have the macro check total lines itself automatically, rather then interrupting the macro's sub-routine.

Jeek gravatar imageJeek ( 2021-04-26 02:02:03 +0200 )edit
1

You say you are using a .txt file and your question is tagged Draw. How are you using Draw with .txt files?

ve3oat gravatar imageve3oat ( 2021-04-26 03:37:22 +0200 )edit

Then when you write "# lines", what you actually mean? are you talking about a line as any amount of text between two line breaks (various depending on TXT kind: Linux/macOS line ends differ from Windows line ends), which usually would translate into paragraph count (but would also be more complex if import is not configured correctly to consider proper kind of line ends, or if the file includes several kinds of line ends), or the lines that result from laying out (and wrapping) that text in some component of LibreOffice (e.g., in a text box in Draw)?

Maybe your macro wants to read a text file itself (e.g., using "com.sun.star.ucb.SimpleFileAccess" and "com.sun.star.io.TextInputStream" services), and so is in fact not specific to used component?

Mike Kaganski gravatar imageMike Kaganski ( 2021-04-26 10:19:42 +0200 )edit

"How are you using Draw with .txt files ? "

Macro to read .txt file, and then output desired data (strings/text/etc) to multiple draw pages via textbox(es).

Jeek gravatar imageJeek ( 2021-04-26 15:36:10 +0200 )edit

See answer by @regina to this question for an example of the code to read a text file line by line.

Mike Kaganski gravatar imageMike Kaganski ( 2021-04-26 16:49:11 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2021-04-26 15:45:06 +0200

erAck gravatar image

In a decent command line shell enter wc -l filename.txt

edit flag offensive delete link more

Comments

Seems it's possible with a no so decent command line link text like type *.EXT | find /c /v "" :)

m.a.riosv gravatar imagem.a.riosv ( 2021-04-26 19:56:30 +0200 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2021-04-26 00:16:15 +0200

Seen: 55 times

Last updated: Apr 26