Reading INI files with dashes in the section name

I am trying to read an INI file from a web site. Within that INI file are sections that have dashes in them. I need to be able to read several sections so I can locate specific files to download referenced within the INI files. I found a script for parsing
INI files, but when I run it, the script fails to handle the sections that have dashes. Any ideas on how I can work around the issue?
$Web = New-Object System.Net.WebClient
Function Get-INIContent ($ContentList){
$INI = @()
Switch -regex ($contentList)
"^\[(.+)\]"
[string]$Section = $Matches[1]
$INI[$Section] = @{}
$CommentCount = 0
$ContentList = $Web.Downloadstring("http://download.nai.com/PRODUCTS/COMMONUPDATER/avvdat.ini")
Get-INIContent $contentlist
What I was hoping to do was search through the INI until I found the sections I want, and then read the fields for that section so I know what to download.  I won't be pulling all of the files, so I need to find a way to search for the sections I am
looking for then read all of the lines for that section and process them.

Found part of the problem... When I pull the file into a variable I lose the ability to search it line by line.  For example:
$Web = New-Object System.Net.WebClient
$ContentList = $Web.Downloadstring("http://download.nai.com/PRODUCTS/COMMONUPDATER/avvdat.ini")
#For some reason this returns the entire file
$contentlist | select -first 1
$contentlist | %{
#Thought this would be one line, but it is also
#the entire file...
$_
I have since shifted to a different method of reading the ini and I can process row by row...
$Web = New-Object System.Net.WebClient
$INILocation = "c:\SomeLocation\avvdat.ini"
$Web.DownloadFile("http://download.nai.com/PRODUCTS/COMMONUPDATER/avvdat.ini",$INILocation)
$INIFile = [System.IO.File]::OpenText($INILocation)
Do {
$CurrentLine = $INIFile.ReadLine()
#This is now one line like it should be.
$CurrentLine
While ($INIFile.EndOfStream -ne $True)

Similar Messages

  • Read ini file with multiple threads

    I have a state machine architecture, but I have multiple threads. For instance, one is dealing with listening for mulitple tcp connections and storing their refnums to an array in a functional global. Another thread is accessing these refnums and collecting data it's receiving from each tcp connection. This data is queued up and then dequeued in a third thread which does some modification and sends it out via serial. My question is, when you have a situation like this and have to read an ini file, where should you read it? It seems like the most logical place would be outside your loops so you can get all the tcp and serial info (port, baud rate, etc) then wire it it to your create listener or initialize serial connection despite them being in different threads. But then again, normal state machine architecture would want an "initialize" case. If you did this though which loop would you put the init case in? And you would then have to worry about synchronizing loops becuase you wouldn't want one to try and create a listener while another thread was still reading ini data which would include the port to listen on. Maybe I'm overthinking this haha. Suggestions? Edit: one more question. Does it seem overkill that I have a tcp loop listening for data and queuing it up and a separate loop sending out the processed data via serial? Or should I just have one state that gets tcp data stores it in a shift register, then another state that sends it out via serial, and returns the state machine to the tcp read state?
    Message Edited by for(imstuck) on 03-03-2010 01:13 PM
    Message Edited by for(imstuck) on 03-03-2010 01:17 PM
    CLA, LabVIEW Versions 2010-2013

    Most of the applications I work on at the moment are used for testing barcode and label printers. The test applications I design are focused on testing the printer's firmware, not the hardware. Within our applications we have three primary objects (Unfortunately they are not native LabVIEW objects yet. They were developed before native LVOOP.) The primary objects we use in our applications are a log object, a connection object (communication interface to the printer) and a printer object. In any single instance of a test we only have a single printer, a single connection to the printer and one or more discrete logs. Each instance of these objects represent a single, real physical entity. A singleton object is a virtual representation of the physical world. Let's take the log object since that is the most simple of the objects described above. Naturally for a given log file you have the log file name and path. We also provide other attributes such as the maximum size of a single file (we allow log files to span multiple files), whether it is a comma delimited file or if it contains raw data, if timestamps should be included with a log entry and so forth. Most of these attributes are static for a log file with the exception of the name and such things as whether the logging is actually enabled or disabled. If we split a wire and had multiple instances of the log file (the way native LVOOP actually works) the attribute for whether logging is currently enabled or disabled will only pertain to the specific instance, or specific wire for the that object. Since this truly represents a single item, one log file, we need that attribute to be shared for all references to the instance of the log object. Since we allow this we can set an attribute on the log object in any task and it will be reflected in any other task that is using it. Think of the way a action engine or functional global works. However, in this case we provide discrete methods for the various actions.
    I hope that made some sense. If not let me know since I just whipped up this response.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Reading csv file how to get the Column name

    Hi,
    I am trying to read a csv file and then save the data to Oracle.
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection c = DriverManager.getConnection("jdbc:odbc:;Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=.;Extensions=csv,txn");
    Statement stmt = c.createStatement();
    ResultSet rs = stmt.executeQuery("select * from filename.csv");
    while(rs.next())
       System.out.println(rs.getString("Num"));
    My csv file looks like this:
    "CHAM-23","COMPANY NAME","Test","12",20031213,15,16
    Number,Environ,Envel,Date,Time
    "1","2",3,"4",5
    "6","7",8,"9",9
    Now is there anyway using the above code I start processing the file from the second row that holds the names of the columns and skip the first row. And also can I get the name of the column using ResultSet something like:
    if columnName.equals("Number")
    Because I may have a csv file that could have more columns:
    "CHAM-24","COMPANY NAME","Test","12",20031213,16,76
    Number,Environ,Envel,Date,Time,Total,Count
    "1","2","3","4","5",3,9
    "6","7","8","9",9",,2
    So I want to get the column name and then based on that column I do some other processing.
    Once I read the value of each row I want to save the data to an Oracle Table. How do I connect to Oracle from my Application. As the database is on the server. Any help is really appreciated. Thanks

    The only thing I could think of (and this is a cluj) would be to attempt to parse the first element of each row as a number. If it fails, you do not have a column name row. You are counting on the fact that you will never have a column name that is a number in the first position.
    However, I agree that not always placing the headers in the same location is asking for trouble. If you have control over the file, format it how you want. If someone else has control over the file, find out why they are doing it that way. Maybe there is a "magic" number in the first row telling you where to jump.
    Also, I would not use ODBC to simply parse a CSV file. If the file is formatted identically to Microsoft's format (headers in first row, all subsequent rows have same number of columns), then it's fine to take a shortcut and not write your own parser. But if the file is not adhering to that format, don't both using the M$ ODBC driver.
    - Saish
    "My karma ran over your dogma." - Anon

  • I can't read a file with the ext PDF the sender informed me that the file was reset to PDF.

    I can't read a file with the .ext PDF the sender informed me that the file was reset to PDF. But when I tried to open it the caption box informed me"the file is not in PDF format. I suspect the sender simply changed the file .ext which is why I can't open it! What can I do about it! I am working on an iPad.
    Thanks
    Mr Jim Lapthorn

    If the document is not, in fact, a PDF, then you will need to get your sender to provide a PDF.
    Can you open this document in any other application?

  • How to configure the .ini file with applet

    hai
    i am using native methods in that methods they use some ip addresses. when i am using that native methods in applet run the applet using appletviewer tool it works fine but when i am open that applet using html page browser not configure that .ini file data .how to configure that .ini file with browser

    Hi Jay SenSharma,
    Thanks for your immediate response.
    I saw your URL links, But in your link give the recursive deployment using wlst. But my question is how to configure the oracle weblogic library files into Admin server & Managed Servers by using the wls.jar file through wlst script to create the new domain.
    But if create the new domain by using GUI mode then we manually give the admin server port number & managed servers port number and name.
    By default the library files are configured with the Admin server in GUI mode. But the Managed server the Library files are not configured with the Managed servers. Then we manually select all the library files to the corresponding managed servers. Then only the applications are deployed into the corresponding managed server.
    Regards,
    S.vinoth Babu

  • I have a problem with the mac can not read video files with the extension IMOD. How can I solve this problem?

    I have a problem with the mac can not read video files with the extension IMOD. How can I solve this problem?

    By doing a Google search. 

  • Labview Read INI File Slow

    Dear ALL:
          I have a VI use OpenG Read INI Cluster subvi to read a complex cluster data structure called step config data,and when I Run this VI,It sometimes read INI File quickly,and sometimes read INI File very slowly.If I want to speed up the read INI File speed,I must quit labview and restart it,and when I quit labview it will reports error just look like Labview Error Message.JPG
    Attachments:
    Labview Error Message.JPG ‏18 KB
    Data Structure.JPG ‏92 KB
    Get Data VI.JPG ‏189 KB

    I've got the same problem - it takes from 4 to 20 SECONDS to write and read 2 ini file clusters.
    The first cluster I write have a few text strings, an error cluster and some numbers.
    The second is an array of clusters (I loop through the array and writes each cluster separately.) containing some text and numbers, most of it contained in sub-clusters.
    With 0 or 1 element in the array it takes around 4 secs to write and read this to ini file. With 20 in the cluster this takes 20 seconds (on a cFP-2120).
    The openG functionality here is quite nice, but if I can't fix this time problem I'm afraid its quite useless!
    Attachments:
    WriteINIFile.jpg ‏211 KB
    IniCluster.jpg ‏114 KB

  • Reading 'ini files'

    I need to write code that reads 'ini files', I would like to know If anyone has a sample or can guide me how to approach this task.
    Thank you

    If you have an ini file with values like :Thank you for your prompt reply. You got me intrigue, By any chance do you know where can I get more information about property files?
    Thank you for your help.
    value1=test
    value2=another test
    You can read the values by doing :
    Properties props = new Properties();
    FileInputStream fis = new
    FileInputStream("D:\\test.ini");
    props.load(fis);
    fis.close();
    String value1 = props.getProperty("value1");
    // etc .........................Note : Unless there is some specific reason you should
    use a properties file and not an ini file.

  • I am getting messages that I can't download and read .pdf files since I have the wrong Adobe reader. I know about their security disasters of course, but I downloaded the latest version of Adobe Reader from the Adobe web site and I have other ,pdf file re

    I am getting messages that I can't download and read .pdf files since I have the wrong Adobe reader. I know about their security disasters of course, but I downloaded the latest version of Adobe Reader from the Adobe web site and I have other ,pdf file readers as well, and for some reason they won't work either. I have 5 computers running top end processors and RAM. By this I mean I have one, this one which I am using that has an AMD Phenom Black 3.2 Quad-core with 8 GBs of Corsair top DDR2 RAM, my other two AMD have either an Athlon II triple core with 4 GBs of DDR2 Corsair RAM, one with the Phenom X4 965 3.4 GHz Quad-core with 8 GBs of their best DDR2 RAM, and two Intels with the i7 920 Processors using the triple channel 1366 socket processors and one with 8 GBs of low latency DDR3 RAM and the other with 4 GBs of the same RAM. I am getting the message on this one, which has a fresh install of XP Pro X64 operating system, as do the other 4 as well. I have run Avast Business Pro Anti-virus on this one, which I am getting the message on with a single result which I deleted, and also both Spybot Search and Destroy, which came back clean as well as Malwarebytes Antimalware, which got a lot of tracing cookies now removed, and SuperAntiSpware which also found a few cookies also now deleted. Can you tell me what I need to do to get these files to show as .pdf files rather than as a clean blank page. One other issue is that I wish to know how to turn off my downloads so they are saved and Mozilla will give me the option of returning them instead of me losing them all together as it does now. Thanks for your assistance. If there is another Adobe reader I should download and install, could you provide me with the link to it? I appreciate your assistance here
    == When I download and try to read a .pdf file and when I am asked to turn off all Firefox files and if I do, I lose them since I need to know how to save them without rebooting my computer.

    Brilliant! Problem solved! Thanks so much.

  • Can't open a file with spaces on the filename.

    Lets say I have a file:
    /home/orv/Open - Me - Please.txt
    When I double click to open that file with any program, the result is something like this:
    "Unable to find /home/orv/Open%20-%20Me%20-%20Please.txt"
    I'm not sure what to call that process of converting the file name so I've been unable to google it up to find a fix or a way to change the behavior of the file manager.
    I've checked the settings in Nautilus and nothings there. Any clues? Thank you!
    Last edited by orv (2007-12-14 23:11:59)

    I tried removing everything in my home directory to erase all settings, still the same problem.
    I tried using a different file manager and still the same problem.
    Here's another example of my problem and its quirks:
    Lets say I have a file called:
    /home/orv/I am a Movie.avi
    In nautilus or thunar, double-clicking that file so I can play it with Mplayer will give an error:
    Failed to open file:///home/orv/I%20am%20a%20Movie.avi
    However, when I drag and drop using the file manager into Mplayer, it works.
    So my problem is this automatic conversion of whitespaces into the %20 which I don't know how to turn off.

  • How can I get the phone numbers in contacts to appear with dashes between the first 3 numbers, the next 3 numbers, and the last 4 numbers?  Until very recently it did so.  Contacts on my macbook pro does show up this way.  I do have a mobile me account an

    How can I get the phone numbers in contacts to appear with dashes between the first 3 numbers, the next 3 numbers, and the last 4 numbers?  Until very recently
    it did so.  Contacts on my macbook pro does show up this way.  I do have a mobile me account and in the past syncing was no problem.  What setting has changed?

    The phone number format as well as the date language and format and the time format are controlled by the Region Format setting. Go to Settings > General >International > Region Format.  When you change a region format, you can go back one page (to International) and see an example of the date/time/phone number format that your selected region format will produce.

  • Temporary files with a "~" in the file name

    when i open an html file i see that another file with the same name, plus a tilde sign (~) after it, is automatically created in the folder that this file sits in. this is supposedly a temporary file? these files are  NOT temporary, they never go away. and they start adding up in my folder and it gets very confusing as to which file i'm working on. sometimes there will be a file with two "~ ~" in them.
    when i close the "original file", the tilde files don't disappear, they stay. On top of that, to make things more confusing, there is also some weird autosave function and i also get files that say filename(Autosaved). Before i know it there are 10 files with various names sitting there and it gets very confusing to know what is the "real" file.  does anyone know how to stop the creation of these "temporary" files? i'm enclosing a screenshot that shows all these files with tildes and the autosaved  file. 

    Sorted. Well sort of. I still have the problem but I know why. Apparently O2 will not allow anyone to send an attachment which has a space in the name. They claim that this reduces spam - no idea why they think that will stop spam but there you go...

  • Error processing cube - requested operation cannot be performed on a file with a user-mapped section open

    Hi,
    We have recently moved our production servers and since the move have been experiencing an intermittent (but frequent) error when processing our OLAP cube.
    The error messages presented are:
    "Error: The following error occurred during a file operation: The requested operation cannot be performed on a file with a user-mapped section open"
    "Error: Errors in the OLAP storage engine: An error occurred while processing index for the <Partition Name> partition of the <Measure Group Name> measure group of the <Cube Name> cube from the <Database Name> database"
    I assume the second message is a consequence of the first error.  The partitions and measure groups seem to vary each time the process is run.
    It appears from similar threads that this is usually caused by backups or anti-virus applications locking the files that Analysis Services is using the process the cube.  I have ensured that there are no backups running at the time of processing and
    I have disabled anti-virus programs without success.
    I have also created a new version of the cube (using the deployment wizard) which deployed without error but then encountered the same error when processing for a second time.  There was nothing (client application wise) using this cube when it failed
    to process.
    As I mentioned earlier, this problem is intermittent.  Sometimes the cube will successfully process but usually it fails to process.
    We have not encountered this error in our previous production environment or in any of our development environments.
    Has anyone encountered this problem before? Any suggestions on possible solutions?
    Thanks
    Rich

    Hi jonesri,
    I think you can try to use SSAS Dynamic Management View to monitor SSAS instance, such as existing connections and sessions. For example, please run the following MDX query:
    SELECT[SESSION_COMMAND_COUNT],
    [SESSION_CONNECTION_ID],
    [SESSION_CPU_TIME_MS],
    [SESSION_CURRENT_DATABASE],
    [SESSION_ELAPSED_TIME_MS],
    [SESSION_ID],
    [SESSION_IDLE_TIME_MS],
    [SESSION_LAST_COMMAND],
    [SESSION_LAST_COMMAND_CPU_TIME_MS],
    [SESSION_LAST_COMMAND_ELAPSED_TIME_MS],
    [SESSION_LAST_COMMAND_END_TIME],
    [SESSION_LAST_COMMAND_START_TIME],
    [SESSION_PROPERTIES],[SESSION_READ_KB],
    [SESSION_READS],[SESSION_SPID],
    [SESSION_START_TIME],[SESSION_STATUS],
    [SESSION_USED_MEMORY],
    [SESSION_USER_NAME],
    [SESSION_WRITE_KB],
    [SESSION_WRITES]
    FROM $SYSTEM.DISCOVER_SESSIONS
    Use Dynamic Management Views (DMVs) to Monitor Analysis Services:
    http://msdn.microsoft.com/en-us/library/hh230820.aspx
    In addition, you can aslo use SQL Profiler to capture some events for further investigation.
    Use SQL Server Profiler to Monitor Analysis Services:
    http://technet.microsoft.com/en-us/library/ms174946.aspx
    If you have any feedback on our support, please click
    here.
    Regards,
    Regards,
    Elvis Long
    TechNet Community Support

  • Is there a procedure to open keynote 09 files with videos in the new Keynote without converting videos?

    is there a procedure to open keynote 09 files with videos in the new Keynote without converting videos?
    I have a big presentation with many video mov and avi files created with Keynote 09. When trying to open the file in the new Keynote the procedured crashes and Keynote crashes abruptly. It seens that an avi file is not converted. I have no more the old Keynote 09. How can this problem be solved?

    if you right click or control click on the file, do you get an option to 'show package contents'?

  • Read a file with a variable=counter : NAMEFILE001,NAMEFILE002..

    Hello,
    I would need your councils.
    I can read a logical file on my server(logical example of name: NAMEFILE) with function FILE_GET_NAME.
    But I would like to be able to read a file with a counter i.e.
    the first time: to read NAMEFILE001;
    the second time read NAMEFILE002;
    the third time read NAMEFILER003...
    How made you that?
    With function FILENAME_EXIT _?
    But, where do I put the variable = counter? In a table...?
    Thank you in advance of your answer
    Servane

    Hi Servane,
    You could also do the following:
    in transaction FILE you set up the physical path name as follows:
    /<i>path</i>/.../<FILENAME><PARAM_1>
    then you call the function FILE_GET_NAME:
      CALL FUNCTION 'FILE_GET_NAME'
           EXPORTING
             LOGICAL_FILENAME        = W_LOGICAL_FILENAME
             PARAMETER_1             = W_FILENUMBER
          IMPORTING
               FILE_NAME               = THEFILE
           EXCEPTIONS
                FILE_NOT_FOUND          = 1
                OTHERS                  = 2.
    This will equally construct the name/counter as you wish.
    AND, if I am not wrong, since the system does it, you will not have to worry about putting the last counter value away in the DB.
    cheers,
    Phil
    Message was edited by: Phillip Morgan

Maybe you are looking for

  • Problem with a Data Source in Web Logic

    Hi everybody, Currently i am deploying a 11g ADF application, i am testing my application in a Web Logic 10.3.2.0, and in the beginning all works OK, but when the user test the application like a half of hour the data source throws this exception: Me

  • Why can't I get a new ringtone (song) on my iphone 5c ?

    Why can't I get a new ringtone (song) on my iphone 5c?

  • Unable to make in game purchase

    Hi, I just updated my credit card details under my account. And I tried to make in game item purchase, but they are asking me to "please contact iTunes support to complete this transaction". May I know how do I overcome this message? My country iTune

  • Cisco Prime Assurance install Help..!!!! :( :(

    Hi all, We would like to bring cisco prime assurance 9.1 in to our Organization Guys could you please provide me install guide or screen shot of the  application for the assurance version 9.1 and I wanted to know the prerequisite  for this applicatio

  • Hotbackup steps...........

    hi see my backup steps and analyze it 1.     put the tablespace BEGIN backup mode as follows: alter tablespace tablespace_name begin backup; 2.     Backup all the database files associated with the tablespace 3.     Set the tablespace in END backup m