Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 18, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 18, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 18, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 18, 2025

      I need to see more from Lenovo’s most affordable gaming desktop, because this isn’t good enough

      May 18, 2025

      Gears of War: Reloaded — Release date, price, and everything you need to know

      May 18, 2025

      I’ve been using the Logitech MX Master 3S’ gaming-influenced alternative, and it could be your next mouse

      May 18, 2025

      Your Android devices are getting several upgrades for free – including a big one for Auto

      May 18, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      YTConverter™ lets you download YouTube videos/audio cleanly via terminal — especially great for Termux users.

      May 18, 2025
      Recent

      YTConverter™ lets you download YouTube videos/audio cleanly via terminal — especially great for Termux users.

      May 18, 2025

      NodeSource N|Solid Runtime Release – May 2025: Performance, Stability & the Final Update for v18

      May 17, 2025

      Big Changes at Meteor Software: Our Next Chapter

      May 17, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      I need to see more from Lenovo’s most affordable gaming desktop, because this isn’t good enough

      May 18, 2025
      Recent

      I need to see more from Lenovo’s most affordable gaming desktop, because this isn’t good enough

      May 18, 2025

      Gears of War: Reloaded — Release date, price, and everything you need to know

      May 18, 2025

      I’ve been using the Logitech MX Master 3S’ gaming-influenced alternative, and it could be your next mouse

      May 18, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»CodeSOD: Counting it All

    CodeSOD: Counting it All

    November 5, 2024

    Since it’s election day in the US, many people are thinking about counting today. We frequently discuss counting here, and how to do it wrong, so let’s look at some code from RK.

    This code may not be counting votes, but whatever it’s counting, we’re not going to enjoy it:

    case LogMode.Row_limit: // row limit excel = 65536 rows
        if (File.Exists(personalFolder + @"" + fileName + ".CSV"))
        {
            using (StreamReader reader = new StreamReader(personalFolder + @"" + fileName + ".CSV"))
            {
                countRows = reader.ReadToEnd().Split(new char[] { 'n' }).Length;
            }
        }
    

    Now, this code is from a rather old application, originally released in 2007. So the comment about Excel’s row limit really puts us in a moment in time- Excel 2007 raised the row limit to 1,000,000 rows. But older versions of Excel did cap out at 65,536. And it wasn’t the case that everyone just up and switched to Excel 2007 when it came out- transitioning to the new Office file formats was a conversion which took years.

    But we’re not even reading an Excel file, we’re reading a CSV.

    I enjoy that we construct the name twice, because that’s useful. But the real magic of this one is how we count the rows. Because while Excel can handle 65,536 rows at this time, I don’t think this program is going to do a great job of it- because we read the entire file into memory with ReadToEnd, then Split on newlines, then count the length that way.

    As you can imagine, in practice, this performed terribly on large files, of which there were many.

    Unfortunately for RK, there’s one rule about old, legacy code: don’t touch it. So despite fixing this being a rather easy task, nobody is working on fixing it, because nobody wants to be the one who touched it last. Instead, management is promising to launch a greenfield replacement project any day now…

    [Advertisement]
    Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleBecome an Open Source Master
    Next Article Tosca Automation Tutorial: Model-Based Approach

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 18, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-4873 – PHPGurukul News Portal SQL Injection Vulnerability

    May 18, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    How to level up your Git game with GitHub CLI

    Development

    This AI Paper Explores Embodiment, Grounding, Causality, and Memory: Foundational Principles for Advancing AGI Systems

    Machine Learning

    Best Microsoft Bookings Alternatives for Seamless Scheduling

    Operating Systems

    Why Security Should Be a Top Priority in Mobile App Development?

    Development

    Highlights

    Development

    RansomHub Double Threat: Florida Health Dept. & NTT DATA Romania Targeted

    July 2, 2024

    The Florida Department of Health, the first accredited public health system in the United States,…

    Elevate healthcare interaction and documentation with Amazon Bedrock and Amazon Transcribe using Live Meeting Assistant

    August 21, 2024

    Chrome on Windows ARM is getting Video Acceleration Boost and better battery life

    June 28, 2024

    Apple and Google Launch Cross-Platform Feature to Detect Unwanted Bluetooth Tracking Devices

    May 14, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.