comstrader

u/comstrader


r/dataengineering•

I have some nested jsons I need to "flatten" in databricks, but I don't need all the fields.

I have a list of the required fields.

What's the best way to go about transforming the data into csv/dataframe?

I have two options I thinking:

  1. Flatten everything, then drop what's not needed (the issue here is that when I flatten the data I get a lot more rows and I'm not sure how to select the ones to drop). When I try json_normalize() on an entire json locally it quickly goes from say 80 columns and 5000 rows to over 150 columns and 100k+ rows.
  2. Build the dataframe by getting the desired columns and rows from the jsons using only the desired fields.
  3. another method?

​

​

10

r/reactjs•

I want to adjust the color and size of an svg image "headset.svg".

Before I was using next/image:

<Image

src={'/headset.svg'} alt='logo' width={30} height={30} className='object-contain' />

This works well for the size but I want to change the color (in css) as well.

I've added the svgr tool to make a component of the svg image.

next.config.js:

module.exports = {
webpack(config) {
  config.module.rules.push({
    test: /\.svg$/i,
    issuer: /\.[jt]sx?$/,
    use: ['@svgr/webpack'],
  })
  return config
},

}

Now I try:

import Logo from '../public/headset.svg';

... <Logo className='w-[50px] h-[5

111

r/nextjs•

I want to adjust the color and size of an svg image "headset.svg".

Before I was using next/image:

<Image
  src={'/headset.svg'}
  alt='logo'
  width={30}
  height={30}
  className='object-contain'
/>

This works well for the size but I want to change the color (in css) as well.

I've added the svgr tool to make a component of the svg image.

next.config.js:

module.exports = {
    webpack(config) {
      config.module.rules.push({
        test: /\.svg$/i,
        issuer: /\.[jt]sx?$/,
        use: ['@svgr/webpack'],
      })
      return config
    },
  }

Code:

import Logo from '../public/headset.svg';
...
<
14

r/reactjs•

I'm trying to compile a nextjs app but I keep getting errors like:

warn  - The `app` dir is experimental. Please add `{experimental:{appDir: true}}` to your `next.config.js` to enable it
info  - Linting and checking validity of types ...warn  - The `app` dir is experimental. Please add `{experimental:{appDir: true}}` to your `next.config.js` to enable it
warn  - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config

Failed to compile.

./components/CustomTexts.jsx
3:45  Error: Strings must use singlequote.  quotes
4:1  Error: `framer-motion` import should occur before
28

r/AskProgramming•

I'm trying to compile a nextjs app but I keep getting errors like:

warn  - The `app` dir is experimental. Please add `{experimental:{appDir: true}}` to your `next.config.js` to enable it
info  - Linting and checking validity of types ...warn  - The `app` dir is experimental. Please add `{experimental:{appDir: true}}` to your `next.config.js` to enable it
warn  - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config

Failed to compile.

./components/CustomTexts.jsx
3:45  Error: Strings must use singlequote.  quotes
4:1  Error: `framer-motion` import should occur before 
11

r/nextjs•

I'm trying to compile a nextjs app but I keep getting errors like:

3:45 Error: Strings must use singlequote.

Here is a snapshot:

​

https://preview.redd.it/n5mbk7i778wa1.png?width=3086&format=png&auto=webp&v=enabled&s=f3b8ea12c097d7a7521e8d039272c1e43ed44bc0

I added rules in both eslintrc files (eslintrc.js and eslintrc.json) "jsx-quotes": "off" but it doesn't make a difference.

Here is my eslintrc.json:

{
  "extends": "next/core-web-vitals",
  "rules": {
    "jsx-quotes": "off"
  }
}

"extends": "next/core-web-vitals", "rules": { "jsx-quotes": "off"   } }

And my eslintrc.js with the "jsx-quotes" rule at the bottom:

module.exports = {
  
30

r/reactjs•

I want to convert a component "ProductList" from a class component to a function component and I'm stuck with this section:

...
<div>
  {
    this.products.map(p =>
      <ProductItem key={ p.id } product={ p }
        callback={ this.props.addToOrder } />)
  }
</div>
...
get products(): Product[] {
  return this.props.products.filter(p => this.state.selectedCategory === "All"
    || p.category === this.state.selectedCategory);
}
...

Here is the entire component file with the original class code commented out (copied from Essential Typescript book):

//Component to display components productItem, categoryLi
06

r/AskProgramming•

I'm following code from a book (Essential Typescript) and confused why it's not loading after the latest changes.

Here is my index.ts:

import { RemoteDataSource } from "./data/remoteDataSource";
import { HtmlDisplay } from "./htmlDisplay";
import "bootstrap/dist/css/bootstrap.css";

let ds = new RemoteDataSource();

function displayData(): Promise<HTMLElement> {
    let display = new HtmlDisplay();
    display.props = {
        dataSource: ds
    }
    return display.getContent();
}

document.onreadystatechange = () => {
    if (document.readyState === "complete") {
        displayData().then(elem => {
    
10

r/learnprogramming•

I have the following code from "Essential Typescript" I'm trying to understand:

import { Product, Order } from "./entities";

export type ProductProp = keyof Product;

//Promise fetches data in background and uses async/await 
//keywords to express the code that depends on those operations
export abstract class AbstractDataSource {
    private _products: Product[];
    private _categories: Set<string>;
    public order: Order;    
    public loading: Promise<void>;

    constructor() {
        this._products = [];
        this._categories = new Set<string>();
        this.order = new Order();
        this.
10

r/AskProgramming•

I have the following code from "Essential Typescript" I'm trying to understand:

import { Product, Order } from "./entities";

export type ProductProp = keyof Product;

//Promise fetches data in background and uses async/await 
//keywords to express the code that depends on those operations
export abstract class AbstractDataSource {
    private _products: Product[];
    private _categories: Set<string>;
    public order: Order;    
    public loading: Promise<void>;

    constructor() {
        this._products = [];
        this._categories = new Set<string>();
        this.order = new Order();
        this.
13

r/webdev•

So something like camelcamelcamel.com, or even better a website that would fetch data from multiple sources (e.g Amazon, Walmart, Costco etc.), or any aggregator site with a search function.

Is there a way to see where/how they fetch data? Like using APIs dynamically, or fetching data from a server, etc. The experience sometimes seems instant.

​

Can I use chrome dev tools to see where the data comes from and how it's fetched?

​

Would an aggregator style website store data on its own server? (or cloud), and setup regular polling to keep it up to date? Or it would always get the data using an API if available, or scraping the data from

35

r/learnprogramming•

So something like camelcamelcamel.com, or even better a website that would fetch data from multiple sources (e.g Amazon, Walmart, Costco etc.), or any aggregator site with a search function. Is there a way to see where/how they fetch data? Like using APIs dynamically, or fetching data from a server, etc. The experience sometimes seems instant.

Can I use chrome dev tools to see where the data comes from and how it's fetched?

Would an aggregator style website store data on its own server? (or cloud), and setup regular polling to keep it up to date? Or it would always get the data using an API if available, or scraping the data from the source when a user requests it?

13

r/reactjs•

I'm trying to pass an id in a path to a component. Here is my route-config.ts file:

...
import EditMovie from "./movies/EditMovie";

const routes = [
   ...
  {path: '/genres/edit/:id(\\d+)', component: 
EditGenre},
...
];

export default routes;

And the component file that isn't loading EditGenre.tsx:

import { useParams } from "react-router-dom"

export default function EditGenre(){
  const {id}: any = useParams();
  return (
    <>
      <h3>Edit Genre</h3>
      The id is {id}
    </>
  )
}

The other pages (routes) work fine, even "http://localhost:3000/genres/edit", except when I go to

12

You've reached the end of this feed.