![]() |
|
![]() | ||
|
Subject:
Excel: Import parentheses correctly from .csv files.
Category: Computers > Software Asked by: fuciek-ga List Price: $4.00 |
Posted:
04 Nov 2002 18:58 PST
Expires: 15 Nov 2002 15:41 PST Question ID: 98987 |
![]() | ||
|
There is no answer at this time. |
![]() | ||
|
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: davidmaymudes-ga on 04 Nov 2002 20:48 PST |
how about using a little program to just remove all of the parentheses from the .csv file before importing it into Excel? |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: noahtall-ga on 04 Nov 2002 22:02 PST |
I looked at your .csv file and it doesn't contain any values in parentheses. What it contains is negative numbers. Here is clear text of the first three lines: Variable,esti01,esti02,esti03,esti04,esti05,esti06 Intercept,0.163596389,-0.023216279,0.000711402,0.044652934,-0.007882827,-0.000212302 ,-0.035514101,-0.027027699,-0.032128626,-0.031581957,-0.027900044,-0.026563415 So you are not having (0.035514101) misinterpeted as a negative number....it is a negative number. Your SAS routine isn't outputting what you think it is. |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: companswerguru-ga on 04 Nov 2002 22:16 PST |
If I understand your question correctly, your problem is that Excel decides that the values surrounded by parentheses are negative numbers One way around this problem is to first rename your .csv file to a .txt file, then when you open it with Excel it will let you import it as a comma delimited file, but instead of letting the columns be "general" format change them to "text" and the values that have parentheses will stay as such. Now in regards to the ( .) values you could do a search and replace for each one of those replacing it with (0.0) Another way to fix the way Excel displays negative numbers is to highlight the whole row, for example Row 5 and then under the Format menu choose Cells and tell the cells to be a number with 5 decimal places with () around negative numbers. I hope this helps... just in case a researcher doesnt take up the challenge of making a script for you. |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: companswerguru-ga on 04 Nov 2002 22:21 PST |
In regards to the .csv file you posted. it is true that there are no values with () except the ones with just ( .) In making my previous comment I assumed that you had just saved the .csv file from Excel and therefore destroying your original file. |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: noahtall-ga on 04 Nov 2002 22:34 PST |
Here is a start. Assuming the .csv is correct, and the sheet in excel is named "nov3", AND that the first column in the standard error row is BLANK, run this macro; Sub mr_fixit() For Each rw In Worksheets("nov3").Rows If Range("a" + Trim(Str(rw.Row))).Value = "" Then Rows(Trim(Str(rw.Row)) + ":" + Trim(Str(rw.Row))).Select Selection.NumberFormat = "0.00000_);(0.00000)" End If Next rw End Sub |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: rac-ga on 04 Nov 2002 22:34 PST |
Hi, I will try to write a vba macro as needed by you be End of day. RAC |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: noahtall-ga on 04 Nov 2002 22:41 PST |
Oh, I forgot about the ( .) to be replaced by blanks. Here is an updated macro which does the replacement for you. Sub mr_fixit() For Each rw In Worksheets("nov3").Rows If Range("a" + Trim(Str(rw.Row))).Value = "" Then Rows(Trim(Str(rw.Row)) + ":" + Trim(Str(rw.Row))).Select Selection.NumberFormat = "0.00000_);(0.00000)" End If Next rw Cells.Replace What:="( .)", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False End Sub It's not as all inclusive as you wanted, but I hope this helps. |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: rac-ga on 05 Nov 2002 05:47 PST |
Hi, Try the following macro which will work as you want. Sub FormatCSV() ' Macro recorded 11/5/02 by RAC 'Select file to open fileToOpen = Application.GetOpenFilename("Text Files (*.csv), *.csv") If fileToOpen = False Then MsgBox "No File selected. Try again" Exit Sub End If 'Open the file Workbooks.OpenText FileName:=fileToOpen, Origin:=xlWindows, _ StartRow:=1, DataType:=xlDelimited, Comma:=True 'Count the no of columns Set acell = Range("A1") colcount = 0 Do While acell.Value <> "" colcount = colcount + 1 Set acell = acell.Offset(0, 1) Loop 'Loop each row For Each rw In Worksheets(1).Rows If Range("B" & (rw.Row)).Value = "" Then Exit For End If If Range("a" & (rw.Row)).Value = "" Then Set acell = Range("B" & (rw.Row)) Count = 2 Do While Count <= colcount If Right(acell.Value, 2) = ".)" Then acell.Value = "" Else acell.Value = Abs(acell.Value) acell.NumberFormat = "(General)" End If Count = Count + 1 Set acell = acell.Offset(0, 1) Loop End If Next rw 'Get save file Name savefile: Do saveFileName = Application.GetSaveAsFilename("Sample1.xls") Loop Until saveFileName <> False On Error GoTo savefile ActiveWorkbook.SaveAs FileName:=saveFileName, FileFormat:=xlNormal MsgBox "Processing Over" End Sub How to Run: Copy this macro. Open a new Excel file. In the tools menu --Macro--Visual Basic Editor. Paste the macro in the VB editor screen. Save it. To run it Open the excel file. from menuTools-->Macro-->Macros-->Select the macro name and Select Run. It will show a file open dialog box. It put the csv file to open After processing will show a file save as dialog box. Give save as filename. After saving as xls file will show a msg box "processing over" If you need any further clarification Please let me know. Thanks, RAC |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: rac-ga on 05 Nov 2002 10:51 PST |
Hi, Can you explain in detail what is not working? What is the error? It will be helpful to analyse the problem better. For your referance I posted the following 3 files in the website. 1. http://rac-ga.tripod.com/nov3.xls This file contains only the macro formatCSV(). This xls sheet contains one tool bar butten(yellow face icon with tool tip "File Update". So by pressing the button you can run the macro. 2. http://rac-ga.tripod.com/nov32.csv This file contains the csv file downloaded from your site. 3.http://rac-ga.tripod.com/sample3.xls Processed output saved as xls file. Thanks, RAC |
Subject:
Re: Excel: Import parentheses correctly from .csv files.
From: rac-ga on 06 Nov 2002 11:33 PST |
Hi Shawn, Nice to note that the macro is working fine and helped in solving your problem. As of now, I am not a paid researcher of Google, So forget about fees. Thanks, RAC |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |