logo
down
shadow

How can I read data from file ? I can't fix it


How can I read data from file ? I can't fix it

By : Armith Pm
Date : October 23 2020, 06:10 PM
Hope that helps As of now you are closing the file immediately after reading each time.
code :
    fscanf(fin, "Class Number : %d\nStudent Name : %s %s Student Number : %d Student Score : %d\n\nClass Average is : %f",&x.classNum, &x.Name, &x.Surname, &x.StudentNumber, &x.EnglishScore, &x.average);

   fclose(fin)


Share : facebook icon twitter icon
How to use Node.js to read data from a json file and display the read data into html?

How to use Node.js to read data from a json file and display the read data into html?


By : Yang Sun
Date : March 29 2020, 07:55 AM
Hope that helps The http module doesn't support Objects as a response (it supports buffers or a strings) so you have to do this:
code :
res.end(JSON.stringify(data));
res.send(data);
How to read the file, put data in JTable, then modify cell/delete lines and save data to the file?

How to read the file, put data in JTable, then modify cell/delete lines and save data to the file?


By : ramesh
Date : March 29 2020, 07:55 AM
this will help I need to read the date from the .txt file put it into JTable in my GUI, then modify some records or delete some lines and save new data to the file. I can do the reading and show JTable but how to edit the date or delete some lines in JTable using GUI then save it to the file? ,
but how to edit
code :
import java.awt.*;
import java.awt.event.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.swing.*;
import javax.swing.table.*;

public class ItemDeletion extends JPanel
{
    private JList<String> list;
    private JTable table;

    public ItemDeletion()
    {
        setLayout( new BorderLayout(5, 5) );

        String[] items =
        {
            "One",
            "Two",
            "Three",
            "Four",
            "Five",
            "Six",
            "Seven",
            "Eight",
            "Nine",
            "Ten"
        };

        //  Add the list

        DefaultListModel<String> listModel = new DefaultListModel<String>();

        for (String item: items)
            listModel.addElement( item );

        list = new JList<String>( listModel );


        JButton listDelete = new JButton( "Delete From List" );
        listDelete.addActionListener( new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                DefaultListModel model = (DefaultListModel)list.getModel();
                int row = list.getSelectedIndex();

                while (row != -1)
                {
                    model.removeElementAt( row );
                    row = list.getSelectedIndex();
                }
            }
        });

        JPanel listPanel = new JPanel( new BorderLayout(5, 5) );
        listPanel.add(new JScrollPane( list ), BorderLayout.CENTER);
        listPanel.add(listDelete, BorderLayout.PAGE_END);

        //  Add the table

        DefaultTableModel tableModel = new DefaultTableModel(0, 1);
        List<String> tableItems = Arrays.asList( items );
        Collections.shuffle( tableItems );

        for (String item: tableItems)
        {
            System.out.println( item );
            tableModel.addRow( new String[]{item} );
        }

        table = new JTable( tableModel );

        table.setAutoCreateRowSorter(true);
        ((DefaultRowSorter)table.getRowSorter()).toggleSortOrder(0);

        JButton tableDelete = new JButton( "Delete From Table" );
        tableDelete.addActionListener( new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                DefaultTableModel model = (DefaultTableModel)table.getModel();
                int row = table.getSelectedRow();

                while (row != -1)
                {
                    int modelRow = table.convertRowIndexToModel( row );
                    model.removeRow( modelRow );
                    row = table.getSelectedRow();
                }
            }
        });

        JPanel tablePanel = new JPanel( new BorderLayout(5, 5) );
        tablePanel.add(new JScrollPane( table ), BorderLayout.CENTER);
        tablePanel.add(tableDelete, BorderLayout.PAGE_END);

        add(listPanel, BorderLayout.LINE_START);
        add(tablePanel, BorderLayout.LINE_END);
    }

    private static void createAndShowGUI()
    {
        JFrame frame = new JFrame("Multiple Item Deletion");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new ItemDeletion(), BorderLayout.NORTH);
        frame.setLocationByPlatform( true );
        frame.pack();
        frame.setVisible( true );
    }

    public static void main(String[] args)
    {
        EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                createAndShowGUI();
            }
        });
    }
}
for (each row);
{
    StringBuilder sb = new StringBuilder();

    for ( each column)
    {
        Object data = model.getValueAt(...);
        sb.append( data.toString() );
    }

    write the sb.toString() to the file
}
How can I use VBA to read and store the file path, creation data, modified data, and other file information of thousands

How can I use VBA to read and store the file path, creation data, modified data, and other file information of thousands


By : pic dumidi
Date : March 29 2020, 07:55 AM
will help you Yes, that can be done with VBA, but it's a lot easier to do it with Power Query, which is a free add-in from Microsoft for Excel 2010 and 2013, and built into 2016 as "Get and transform".
Start a new query "From File > From Folder", select the folder you want. You can edit the query to remove columns you don't need. No coding required.
Create text file dynamically in a specified directory, write data,read data from that file in java

Create text file dynamically in a specified directory, write data,read data from that file in java


By : user9255171
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Recently i have tried to write code of above given title and the problem is that i could not get sufficient date to write upon have a look at my code .it is showing some errors like , Please find the code and then you can use
code :
**Writing** : PrintWriter,Scanner,BufferedWriter etc to write to that file
**Reading** :FileReader,BufferReader,Scanner with these readers etc

String path = "G:"+File.separator+"Software"+File.separator+"Files";
    String fname= path+File.separator+"fileName.txt";
        File f = new File(path);
        File f1 = new File(fname);
        f.mkdirs() ;
        try {
            f1.createNewFile();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
read data from multiple files but would like to write that data into a new text file but file shows up blank

read data from multiple files but would like to write that data into a new text file but file shows up blank


By : romain
Date : March 29 2020, 07:55 AM
Does that help I think you should change the order of opening files to the following. The problem is that for each file you open to read, you're also re-opening the file to write, whipping it's contents.
Also, due to the break you will write at maximum one line per file due to the break after the write statement. If the last file that you opened does not have any match with the regular expression, then nothing will exist in the final file.
code :
directory = 'C:\Assignments\\CPLfiles\*'
test = False
start_text = '^GMWE'

with open('file.txt', 'w') as f1:
    for filename in glob.glob(directory):
        with open(filename) as f:
            for line in f:
                #for x in line:
                    if test is False:
                        if re.search(start_text, line.strip()) is not None:
                            x = line.strip()
                            f1.write(x+ '\n')
                            print(x)
                            break


    test = False
Related Posts Related Posts :
  • Problem with C function of type char pointer, can someone explain?
  • Macros in C.... please give the solution
  • Unix Piping using Fork and Dup
  • Any difference between these two while loops?
  • Hashtable implementation for C
  • Problems with Linked List in C
  • Stack Allocation in C
  • Random function stuck on one number
  • printf following zeros to a certain degree
  • Measuring CPU clocks consumed by a process
  • How is a CRC32 checksum calculated?
  • Tips on redefining a register bitfield in C
  • Converting a program from c to bash script
  • Static library not included in resulting LLVM executable
  • What is the meaning of "wild pointer" in C?
  • Reading DWORD from binary file
  • Efficient way to find divisibility
  • Whats the fastest, portable way to hash pointers we know are pointer aligned to a fixed size int?
  • Why does my summation program behaves weird?
  • How to determine values saved on the stack?
  • Thread scheduling C
  • C - converting to 2s complement
  • wireless networks c program
  • From where does the uboot get the information about flash, RTC, RAM in uboot/kernel development
  • printf behaviour in C
  • Measure size and way-order of L1 and L2 caches
  • Efficient copy of entire directory
  • Efficient way to create/unpack large bitfields in C?
  • getnameinfo prototype asks for sockaddr not sockaddr_in?
  • Linked List Sorting with Strings In C
  • Typecasting a floating value or using the math.h floor* functions?
  • Problem implementing sorting algorithm in C with an array of structs
  • How to copy a ram_base file to disk efficiently
  • How to fix casting a pointer to an integer?
  • How to round floating point numbers to the nearest integer in C?
  • PIC C - Sending 200 values over USB, but it only sends 25 or so of them
  • How do you return a string from a function correctly in Dynamic C?
  • Monotonic clock on IRIX
  • setsockopt (sys/socket.h)
  • How to make C program wait (on Linux)?
  • i find a problem using atoi() method in ansi c?
  • Why is this array being initialized in an odd way?
  • How to execute commands in chroot?
  • Microsecond (or one ms) time resolution on an embedded device (Linux Kernel)
  • Question about variable definitions in functions
  • SMTP on C: STARTTLS via OpenSSL
  • fetch value of ipaddress
  • Binary expressions in C
  • Why do char * and char ** have the same value?
  • problem in allocating kernel memory by malloc() from user space?
  • dangling pointer, reason for value change after free()?
  • How to compile C program with multiple files in Xcode
  • Can you make an incrementing compiler constant?
  • Reading data from text file in C
  • SQLite's test code to production code ratio
  • Displaying an inverted pyramid of asterisks
  • sd spi mode in C language
  • printf("%2d") in C programming
  • Add a certain number of bytes to a void pointer in C
  • How should I protect against hard link attacks?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk