Ask a Question

I have a notepad having some number stored in it . How to get the row count for that notepad.

Amrendra
Occasional Contributor

I have a notepad having some number stored in it . How to get the row count for that notepad.

I have a notepad having some number stored in it . How to get the row count for that notepad.  attaching the notepad for example. Please help. I need this in Python

3 REPLIES 3
baxatob
Community Hero

with open("trade.txt", "r") as file_:
    rows_array = file_.readlines()

rows_count = len(rows_array)
AlexKaras
Champion Level 2

Hi,

 

Count the number of new-lines in the text.

See the help for GetListLength() method.

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
shankar_r
Community Hero

TestComplete provides below option,

 

def Test():
  fileName = "D:\\Files\\MyFile.txt"
  fileObj = aqFile.OpenTextFile(fileName, aqFile.faRead, aqFile.ctANSI)
  Log.Message(fileObj.LinesCount)
  fileObj.Close()

Ref : https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqtextfile/linescount.html...


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

cancel
Showing results for 
Search instead for 
Did you mean: