Count Number Of Lines In A Text File
Aug 23, 2007Hi there!
I need help on how to count the number of lines in a text file..
Pls. advise
thanks in advance
Hi there!
I need help on how to count the number of lines in a text file..
Pls. advise
thanks in advance
i have a text file that is like:date = OCT0606asdfsdafasdfasdgsdghasdfsdfasdgSTART-OF-DATAasdfasdfgasdfgdfgsfgsadfsdfgsaasdfgsdfgEND-OF-DATAasdfgalsdkdfklmlkmasdfgasdfgi need to clear everything from this file except the data between theSTART-OF-DATA and END-OF-DATA using a batcj file... elternitavly i amopen to suggestions of how to import using bulk insert in sql withoutchanging the file at all. data is pipe seperated but obvioulsy hasplenty of junk data in it. i have 2 similar files at about 30mb and60mb in size. thnks everyone
View 15 Replies View RelatedI have a flat file that look like this
############################################################
# Market Issue Lookup
# Applies to: Muni,Pfd,Govt,Corp
###########################################################
LU_MARKET_ISSUE| |AUSTRALIAN|Corp|
LU_MARKET_ISSUE| |BULLDOG|Corp|
LU_MARKET_ISSUE| |CANADIAN|Corp|
LU_MARKET_ISSUE| |WARRANTS|Muni|
LU_MARKET_ISSUE| |YANKEE|Corp|
############################################################
# Maturity Type Lookup
and i want it to look like this
LU_MARKET_ISSUE| |AUSTRALIAN|Corp|
LU_MARKET_ISSUE| |BULLDOG|Corp|
LU_MARKET_ISSUE| |CANADIAN|Corp|
LU_MARKET_ISSUE| |WARRANTS|Muni|
LU_MARKET_ISSUE| |YANKEE|Corp|
Basically remove any line that start with a "#" or any blank lines..
I am assuming you can do this only using a script component and not directly through ssis..but i am not too familiar with scripting...so some code would be helpful
Thanks for any help in advance.
smathew
I am trying to bcp import a text file into a SQL Server 2000 database.The text file is coming out of a java application where orderinformation is written to the text file. Each record is on it's ownrow, so the last item in each record has a new line character at theend of it to create the next row. This works well in creating the filehowever bcp does not like to import this text file with the extra blankline at the end. If I change the new line character to the beginning ofthe records then there is a blank line at the top of the text file,which bcp also does not like. Does anyone have any suggestions for meto get around this issue?Thanks,
View 6 Replies View RelatedHello,
SQL SERVER 2000:
My problem is that I have to process a special text file every day which contains 0 ASCII values to separate fields. The DTS import program drops everything after the ascii 0 value in the row, but of course I need the entire row with all fields.
So how can I prevent the text file import task from dropping everything after the 0 ascii value?
Could you help me in this?
thank you
I have a task where I need to process roughly 60000 excel spreadsheets and bring them into a SQL Server 2014 database. All excel files have the same format and same number of identical columns. I have set up an SSIS package that is using Foreach Loop Container to look into a folder and process these files one at a time and load them to a table. The mappings are straight-forward, no problems there.
I am attaching a sample spreadsheet with two tabs - current structure and desired structure.
Basically what I need to do is to repeat the first 7 columns based on the number of lines in a transaction.
The number of lines is variable per patient.
Hi guys,
I'm trying to write a producure to count the number of digits in a text.
i.e :
text
---------
12 fff 3 a.z
12345 ggg6gg a
123
Result:
--------
3
6
3
It seems to be real easy via RegEx in C# , but i cant figure it out in SQL.
Thank YOU!
Hello,
I use the full-text search utility in SQL Server 2005 to find word in PDFs document.
This is my 'Documents' table:
id (PK), data (VarBinary(max)), extension (nvarchar(4))
My full-text catalog on 'data' column works fine because when I search 'Microsoft', my document containing this word is returned as result.
SELECT * FROM Documents WHERE freetext([data], 'Microsoft');
1 | 0x255044.... | .pdf
But I need to know how many times 'Microsoft' word appears in this document.
Do you have any idea how can I retrieve this information?
Thanks in advance!
Hello, I'm pretty new to SSIS but so far what I have is a package that exports a SQL Server table to a text file. I needed to add a dynamic header that had the date and time of creation. Now I need to know how many records are being exported and put that number into the header.
For the header I am using a script task in the control flow which works well to put the creation date in the header. The script runs and writes the header and then the data flow exports and appends the records to the same text file. It seems to me since the script runs before the data flow I won't know the amount of records until after the data flow is done.
Maybe I could write the header after the data is gathered but before it is exported. Can anyone make some suggestions?
Basically the text file would be:
2/6/2008
154
Data
Data
Data
...
the 154 would be the total number of records to follow.
While I'm at it can someone tell me how to access the destination file path in the flat file connection? Right now I'm just hardcoding the path into my script.
Thanks,
Gunner
I am developing a report analog of a machine readable form that has to display a static number of detail rows regardless of the number returned from the database - i.e. if a record set has only three detail records, I need to display three blank rows, while if the record set has ten detail records, I need to display six detail records, print the footer, start a new page, repeat the header information, print the remaining 4 detail records and 2 blank rows, print the footer again and move on to the remaining recordset. I am new to report development and I'm having to pick it up on the fly. I can't seem to locate any documentation about how to handle this scenario.
I don't have the time or inclination to re-invent the wheel here, is there anyone who has solved this problem who can point me in the direction of some help?
I have a DTS that reads in a bunch of transactions daily to a tran history table. I read them in from a text file each day. The problem is, that about half of the lines in the text file contain semicolons because they are comments. What I do now is, import the whole thing, and then do a Delete on my tran hist table for all lines with semicolons. As my tranhist table grows, this Delete will start to take a long time. How do I filter it so it doesn't even import the lines with semicolons to start with, that will run faster and save me time later.
Thanks,
Andrew
I have a dtsx package that works fine with one exception. When I open the dtsx package in BI, it gives me the following message:
Document contains one or more extremely long lines of text. These lines will cause the editor to respond slowly when you open the file. Do you still want to open the file?
When I respond yes, the package opens and I can edit or execute with no problem. Still, I want to understand what could cause this message to occur and, more importantly, how I can get rid of the message. When I try to simply execute the package I still get the same error and it seems this will be a problem for trying to run the package from SQL Server agent.
It seems likely to me that this message refers to the dtsx file (in xml format) itself. Does that make any sense?
We are using a table that may give 1 to and unknown number of data elements (ie. years) . Â How can we break this to show only three years in each row. Â Since we don't know the number years we really won't know the number of rows needed. Â Years are stored in their own table by line. Â
Â
car make year1 year2 year3
A Â volare 1995 1996 1997
a  volare 1997  1998  1999
b toyat  1965   1966  1968
We can pivot out the first X# but we don't know how many lines so we don't know how many rows we will be creating.
Hi everybody,
I'm sending text based e-mails using SMS and I need some lines to be bolded. I don't want to switch to HTML based just to make some lines bold. But, I cannot figure out how I can make the lines bold in SMS. I didn't see any options in SMS to bold a line of text. Is there any any function available for varchar datatype that will bold the text or something like that? or will I have to go to HTML based e-mail? any help is greatly appriciated.
devmetz
Hi,
I've created a dataset with 27 measures and 20 query parameters. When attempting to load the report containing this dataset I'm shown the message;
'Document contains one or more extremely long lines of text. These lines will cause the editor to respond slowly when you open the file. Do you still want to open the file.'
If I do open the file it does indeed respond very slowly or even hangs.
I can manually format the XML code but amending the code in any way (i.e. using the layout designer to move a chart) removes my formatting and re-introduces the problem.
Are these an unreasonable amount of measures / parameters?
Environment;
VS2005 v8.0.507
MSSQL 2005 9.00.1399.06 Build 3790 SP2
Windows Server 2003 SP2
Many thanks.
Hi There,
I am parsing a directory of flat files and looping through it with a foreach loop. Some of the files have lines that contain characters that I would like to remove. In fact, it would be good if I could remove the entire line. Is there a way to do this with a Script Task or some other way.
Thanks for your help.
Hi,
I have a very simple question, how do i read the first couple of lines only from a flat file source. Let me illustrate with an example:
**Source file***
Date of refresh 04/05/06 **
abc, 123
bac, 156
I need a way to read the first line 'Date of refresh 04/05/06 **' and get the date '04/05/06' ; and store the date in a variable.
Right now, I have a flat file source and a script component, which receives a connection from the flat file source, The script component is reading the lines, but thrice instead of once. It would be great if I can program the script component to terminate after reading the first line only. Any help would be appreciated very much.
Thanks
Bidyut
Is this possible? I would think it would be, but not sure of the commands and I can't find them in my books.
I'm looking for something like.
EXEC usp_studentassign SPOOL C:
esults.txt
Is there such a beast?
Thanks : )
I can't believe it's been a few days and I can't figure this out. We have a flat file (purchaseOrder.txt) that has header and detail lines. It gets dropped in a folder. I need to pick it up and insert it into normalized tables and/or transform it into another file structure or .NET class.
10001,2005/01/01,some more data
SOME PRODUCT 1, 10
SOME PRODUCT 2, 5
Can somebody place give me some guidance on how to do this in SSIS?
I have used the following useful article regarding exporting a multi-record file:
http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/2007/09/25/multi-record-formated-flat-file-with-ssis.aspx
I have created the 9 datasources, ordering each on a field commmon to all.
I have created the required derived columns headers and have merged all the record types into a file.
The resulting file looks fine, except for the odd blank line between record types. Any ideas regarding cause and what to do to fix?
Any help is most appreciated!
i just want one row instead of multiple rows results.
declare @name varchar(30)
declare @count int
declare @a int
set @name = 'dennis dennis'
set @count = 0
set @a = 1
while(@count < len(@name))
begin
select count(substring(@name, @a, 1)), substring(@name, @a, 1)
where substring(@name, @a, 1) = 'd'
select @count = @count +1
select @a = @a+1
end
hi
can anyone tell me how to count number of records(rows) in a table without using "COUNT" function.for practise iam trying to implement it through queries.
Using linq what would be the most efficient method of counting the number of users in the users table?
View 2 Replies View RelatedThe following SQL works on Access and Oracle to return the number of
Groups(Rows) of the SQL. In MS-SQL this SQL is not valid. What is the
equivalent in MS-SQL?
Select Count(1) FROM (Select ShipRegion, Sum(FREIGHT) as [TotalFreight]
from ORDERS WHERE OrderID < 123456 GROUP BY ShipRegion )
Thanks,
Frankk
hey, how would i count the number of rows, with out using a loop??
thanks, Justin
I have one table tbl_resume.I have store all resume in one column ...RESUME...i have to count Number of words(Skills) used in resume :- JAVA or C++
View 5 Replies View RelatedI know I have had this before, but I can't remember what I did to fix it.I have a field that is varchar. I need to count the numbers up.
Example
Claim Count
37
6
When I do my query
Select Distinct count([Claim]) from Table
It comes up with 2.How do I have it recognize that I need the actual number count? I need it to be 43.
Hi all,Do you know how can I count the number of cubes and number of databasesin SQL Analysis Services using T-SQL?Thanks.
View 2 Replies View RelatedHello, DeanTry this:select distinct c1, c2 into #tmp_1 from t1select count(*) as cnt from #tmp_1drop table #tmp_1With best regards.
View 1 Replies View RelatedHi all,
In the report I am working on, I have a "textbox39" in a table which has groups. I want to have another "textbox29" outside the table to count the number of "textbox39"s that are actually displayed and also the number of "textbox1"s that have a certain value (e.g. "1") in the final report. I tried to use "Sum(ReportItems!textbox39.Value)" but the compiler complains
Error 1 [rsAggregateReportItemInBody] The Value expression for the textbox 'textbox29' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers. d:perfperfreportingprojectPerformanceTestDetails v.3.rdl 0 0
Error 7 [rsReportItemReference] The Value expression for the textbox €˜textbox29€™ refers to the report item €˜textbox39€™. Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope. d:perfperfreportingprojectPerformanceTestDetails v.3.rdl 0 0
Anybody has any idea how to solve it?
Thanks so much,
Zhiyan
Hello;
Which is the easy way to do this:
I have 2 tables:Work_Order_Header and Work_Order_Detail.
I need to generate the Item Number from 1 to "qty of items" when I make the JOIN on WorkOrderNumber.
Example:
WorkOrderNumber WorkOrderItem WorkOrderAmt
122 1 10.00
122 2 15.25
122 3 24.37
How I generate the WorkOrderItem using a select with a JOIN on the 2 tables?
My understanding from a previous thread was that ExecuteNonQuery() could be used to display the number of rows returned.
Does this also work when calling stored procedures and passing parameters?
I have code (shown) that perfectly calls and returns Distinct models downloaded by Country. Yet the rowCount variable displays a -1.
What should I do?Dim myCommand As New SqlClient.SqlCommand
myCommand.CommandText = "ap_Select_ModelRequests_RequestDateTime"
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.AddWithValue("@selectDate", dateEntered)
myCommand.Parameters.AddWithValue("@selectCountry", CInt(selectCountry))
myCommand.Connection = con
con.Open()
Dim rowCount As Integer = myCommand.ExecuteNonQuery()
numberParts.Text = rowCount.ToString
con.Close() Thank you.
hello,
i have a stored procedure SELECT CommentID, UserName, CommentingDate
FROM Comm
WHERE PictureID = @PictureID
ORDER BY CommentingDate DESC
witch shows me the users who commented a Picture with PictureID = x
I need to add two rows at that stored procedure, one to show the number of total comments at that picutre (like counting the number of rows returned) and the second to show count the DISTINCT users who commented that picture
I tryied with COUNT but i have to use GROUP BY and i don't think this is good...
I hope you understand... please help me,
thanks